How can I send bulk email without issue?

I am using Gmail premium account as SMTP for sending email from erp. Usually I’m sending mail for notifying customer. So, the number vary up to 500. When number is below 50 it works fine, whenever the recipient is above 50 I am getting: Invalid Outgoing Mail Server or Port

Here is how I am sending:

Following mail sending code is running inside a for loop.

frappe.enqueue(
                queue="short",
                method=frappe.sendmail,
                recipients=get_recipients(context.get('email')),
                sender=frappe.conf.bekredito['default_mail_sender'],
                subject=frappe.render_template(
                    email_template.subject, context),
                message=message,
                now=True,
            )

How can I resolve this issue?

Please check and read this Email Account
if you configured Email account correct or not

To fix this issue:

  1. Split Recipients: Send emails in smaller batches (e.g., 25-30 recipients per batch) to avoid Gmail’s limits.
  2. Check SMTP Settings: Ensure you’re using the correct Gmail SMTP settings:
  • Server: smtp.gmail.com
  • Port: 587 (TLS) or 465 (SSL)
  • Authentication: Gmail account credentials or App Password if 2FA is enabled.
  1. Use a Dedicated SMTP Service: For bulk emails, consider services like SMTPmart or Mailgun for better deliverability and higher limits.

To fix the issue, use services like DigitalAka or SMTPget for sending many emails. They work better for large numbers and avoid Gmail limits. Also, send emails in small batches instead of all at once.