Reputation: 1376
I am attempting to send bulk email without create new session for every mail recipient because of performance considering.
But i am facing one problem in this. if one of the recipient is invalid, then job could not send mail to other recipients. In this scenario i need to send mail to other recipients
Below is my code snippet, Kindly provide any suggestion for this problem.
Session session = Session.getInstance(props, null);
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(mailFrom));
message.setSubject(subject);
message.setContent(messageStr, "text/html");
if (mailTo != null) {
for (int i = 0; i < mailTo.length; i++) {
message.addRecipient(Message.RecipientType.TO, new InternetAddress(mailTo[i]));
}
}
Transport.send(message);
Upvotes: 1
Views: 160