My email code works well when I just send an email to a few people, but when I sending to all users(177) in contact, I got this error:
[ERROR] - org.apache.commons.mail.EmailException: Sending the email to the following server failed : hlrdwd.com:25
The code is below:
HtmlEmail email = new HtmlEmail();
email.setCharset("utf-8");
if (vo.getContent() != null && vo.getContent().trim().length() > 0) {
email.setHtmlMsg(vo.getContent());
} else {
email.setHtmlMsg(" ");
}
email.setSubject(vo.getTitle());
email.setFrom(vo.getSender(), currentuname);
email.setHostName(Property.getSmtp());
List<Map<String, String>> toList = mm.formatAddress(vo
.getReceiver());
if (toList != null) {
for (int i = 0; i < toList.size(); i++) {
Map<String, String> tMap = toList.get(i);
email.addTo(tMap.get(mm.KEY_EMAIL), tMap.get(mm.KEY_NAME));
System.out.println(tMap.get(mm.KEY_EMAIL));
}
}
email.setAuthentication(currentuser, password);
String messageid = email.send();
I google this and add email.setTLS(true);
, but still can not work. Waiting your help!