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)
- Help me how to resolve it.
- Is there any specific per minute limit on smtp.gmail.com?
Thanks, Rana
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
General recommendations:
Moral: If sending a large amount of email, it's probably best to use your own email server.