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
Below is the method causing Exception.
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.