当我只向几个人发送电子邮件时,我的电子邮件代码运行良好,但是当我发送给所有联系的用户(177)时,我收到了这个错误:
[ERROR] - org.apache.commons.mail.EmailException: Sending the email to the following server failed : hlrdwd.com:25
代码如下:
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();
我谷歌这个并添加email.setTLS(true);
,但仍然无法工作。等待您的帮助!