Reputation: 11
I am getting the following error while sending mails using Java Mail. Below is the error. Could you please let me know the causes on the error.
ERROR :: Sending failed;
nested exception is:
class javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
class javax.mail.SendFailedException: 452 Too many recipients received this hour
;
nested exception is:
class javax.mail.SendFailedException: 452 Too many recipients received this hour
;
nested exception is:
class javax.mail.SendFailedException: 452 Too many recipients received this hour
;
nested exception is:
class javax.mail.SendFailedException: 452 Too many recipients received this hour
;
nested exception is:
class javax.mail.SendFailedException: 452 Too many recipients received this hour
;
nested exception is:
class javax.mail.SendFailedException: 452 Too many recipients received this hour
;
nested exception is:
class javax.mail.SendFailedException: 452 Too many recipients received this hour
public void sendTextReport(DataBean dataBean, TextBean textBean) throws IOException, MessagingException {
Session session = getAuthentication();
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(this.props.getProperty("from")));
message.addRecipients(Message.RecipientType.TO,InternetAddress.parse(this.props.getProperty("textTo")));
message.addRecipients(Message.RecipientType.CC,InternetAddress.parse(this.props.getProperty("textCc")));
message.setSubject(" Report for the submissions between "+ dates.getDate1() + " and " + dates.getDate2());
StringBuilder mailBody = new StringBuilder();
mailBody.append("<text>Hi All,<br><br>Below is the Report for the submissions </text><br><br><br>");
mailBody.append("<table><tr><th>Description</th><th>Count</th></tr>");
LinkedHashMap map=(LinkedHashMap) getTextMap(dataBean,textBean);
Iterator it=map.entrySet().iterator();
while(it.hasNext()){
Entry<String, Integer> entry=(Entry) it.next();
mailBody.append("<tr><td>"+entry.getKey()+"</th><td class='count'>"+entry.getValue()+"</td></tr>");
}
BodyPart messageBodyPart1 = new MimeBodyPart();
messageBodyPart1.setContent(mailBody.toString(), "text/html");
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart1);
message.setContent(multipart);
Transport.send(message);
public Session getAuthentication() {
final String host = this.props.getProperty("from");
final String password = this.props.getProperty("password");
properties.setProperty("mail.smtp.host", this.props.getProperty("hostName"));
Session session = Session.getInstance(properties,null);
return session;
textTo: This string contains 3 email addresses textCc: this String contains 1 Distribution list which has 8 email addresses.
All are valid email addresses. I checked with getValidUnsentAddresses() in SendFailedException.Seems all are valid but not sent.
Upvotes: 0
Views: 2163
Reputation: 1129
This is called grey-listing. When you send too many e-mails (or more often - a certain number of e-mails where a recipient does not exist) a destination mail server does not black list you, but instead they temporarily block access from your mail server (essentially the IP address of your mail server). Usually this block is set for 1 hour but obviously can vary depending on the configuration.
You can do several things:
1.Contact the admins of the domain in question (e.g. [email protected]) and request your IP address to be whitelisted. (They may refuse).
2.Check/increase time e-mails can stay in your local queues (to have more chances of them to retry and finally get delivered.
3.Add more public IP addresses to your server
Upvotes: 1