I am trying to send 500+ emails via a for loop with javaxmail - no Spam, the email adresses are known and certified.
The aim was to have a little time delay (1 - 5 sec) between sending (Thread.sleep(...)), so the mails do not automatically go into the Spam Folder. But after testing some time by sending it to my own email address, I keep getting this error :
com.sun.mail.smtp.SMTPSendFailedException: 554 5.7.0 Your message could not be sent. The limit on the number of allowed outgoing messages was exceeded. Try again later.
I am using our own smtp Server.
properties.setProperty("mail.smtp.auth", "true");
properties.setProperty("mail.smtp.host", host);
properties.setProperty("mail.smtp.port", "25");
I'd like to know how long the time span for "try again later" is?
Does anyone know the limit?
Also any suggestions how to avoid this would be helpful.
In most of the cases you should try to avoid those mass mail sending (spam filters are pretty discriminative on large amount of mails no matter what), but in your case there is a simpler answer. Distributed mail processing is preferred, with time based limit rates etc.
The problem You likely have is that (as the errormsg says) you try to exceed the limit of your outgoing mail number. (You could get further information by examining the getCommand and getReturnCode.) If you are using POSTFIX with policyd here is an example of the outgoing mail limit configuration:
You could "fix" this problem by reconfiguring your SMTP server. Altough my recommendation is (to avoid getting on block list) to split up your whole email sending process:
Those limits are for your own safety in most of the cases. Those prevent you from getting onto blacklists if a software bug occures etc.