Bulk Emails failed with 421 4.7.0 Try again later

2019-06-24 03:44发布

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: abc@org.com To: emp1@org.com

Mail#2 From: abc@org.com To: emp2@org.com

...

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

1条回答
来,给爷笑一个
2楼-- · 2019-06-24 04:16

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:

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:

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.

查看更多
登录 后发表回答