Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bulk Emails failed with 421 4.7.0 Try again later

I have a requirement to send bulk emails with in my organization. I am Java Mail API and sending the mails with below config.

        props.put("mail.transport.protocol", "smtp");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.smtp.host", "smtp.gmail.com");
        props.put("mail.smtp.port", "587");

Mail#1 From: [email protected] To: [email protected]

Mail#2 From: [email protected] To: [email protected]

...

Mails are triggered in a loop.

Problem: First 80 emails sent successfully. From 81st mail I am failing with below error for 10-15 emails and later few mails are sent successfully.

Out of 743 emails 400 Failed & 343 are success.

    INFO   | jvm 1    | 2017/08/18 07:25:54 | com.sun.mail.smtp.SMTPSendFailedException: 421 4.7.0 Try again later, closing connection. (MAIL) xsdsfasdsa.96 - gsmtp
    INFO   | jvm 1    | 2017/08/18 07:25:54 | 
    INFO   | jvm 1    | 2017/08/18 07:25:54 |   at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2108)
    INFO   | jvm 1    | 2017/08/18 07:25:54 |   at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1609)
    INFO   | jvm 1    | 2017/08/18 07:25:54 |   at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1117)
  1. Help me how to resolve it.
  2. Is there any specific per minute limit on smtp.gmail.com?

Thanks, Rana

like image 858
ranafeb14 Avatar asked Aug 18 '17 12:08

ranafeb14


People also ask

Did Google stop SMTP?

Google announced on May 30, 2022, that all SMTP connections will no longer have access to their servers (even with less secure apps turned OFF) meaning any website contact form which was connected through an SMTP connection will simply not send contact forms any longer.


1 Answers

Yes, I think there is a per minute limit for sending SMPT messages via Gmail (around 80 in my experience that of others around 80-100). But it's not a 100% hard limit but some sort of soft limit that is enforced when Gmail thinks its due.

First, check your message queue in G Suite admin area. If the queue is huge and still growing you send too fast.

Some useful links:

  • G Suite SMTP Error Reference
  • Gmail Bandwidth limits for accounts
  • Gmail sending limits in G Suite
  • Bulk Senders Guidelines

There is no further explanation what's wrong when you suffer from the error

421, "4.7.0", Try again later, closing connection.

General recommendations:

  • you could use Pooled SMTP like https://nodemailer.com/smtp/pooled/

If pooling is used then Nodemailer keeps a fixed amount of connections open and sends the next message once a connection becomes available. It is most useful when you have a large number of messages that you want to send in batches or your provider allows you to only use a small amount of parallel connections.

  • do not send too fast
  • do not send more than 50 emails at once
  • do not assume Gmail is a local system. It's an external service that uses sophisticated methods to make email globally available extending a 42-year-old invention that is far from perfect.
  • do not try stupid things or Gmail will punish you.

Moral: If sending a large amount of email, it's probably best to use your own email server.

like image 131
wp78de Avatar answered Oct 05 '22 01:10

wp78de