1
回答
发送邮件不稳定怎么解决

使用 apache commons email 发送邮件 可以发送成功就是连续发送的话,好出现这种错误

 

Sending the email to the following server failed : smtp.gmail.com:465

 

或是

Sending the email to the following server failed : smtp.gmail.com:587

 

我的做法是发送失败,5分钟后再发送一次(每次调用的端口不一样),3次不成功不发了,提示

 

请问有没有更好的解决办法杜绝上面的错误呢啊!

 

 

 

 

举报
快慢机
发帖于6年前 1回/3K+阅
共有1个答案 最后回答: 5年前

java使用企业邮箱发送老是失败是因为什么?

/**
* 简单邮件发送
* @param toUser
* @param subject
* @param msg
*/
public static void send(String toUser, String subject,String msg) {
System.out.println("发送邮件给:" + toUser);
System.out.println("邮件主题为:" + subject);
System.out.println("邮件内容为:" + msg);
config = PropertiesFactory.getPropertiesHelper(PropertiesFile.APP);

SimpleEmail email = new SimpleEmail();
email.setHostName("smtp.exmail.qq.com");
email.setAuthentication("sss@iduo.tv","12345");
//email.setSSL(Boolean.TRUE);
//email.setSslSmtpPort("465");
email.setCharset("UTF-8");
try {
email.addTo(toUser);
email.setFrom("sss@iduo.tv");// 必须和Authentication使用的用户相同,否则失败
email.setSubject(subject);
email.setMsg(msg);
email.send();
} catch (EmailException e) {
e.printStackTrace();
}
}


错误信息:

org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.exmail.qq.com:25
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1410)
at org.apache.commons.mail.Email.send(Email.java:1437)
at com.csmy.my.center.util.mail.EmailUtil.send(EmailUtil.java:44)
at com.csmy.my.center.util.mail.EmailUtil.main(EmailUtil.java:53)
Caused by: javax.mail.AuthenticationFailedException: 454 Error: authentication failed, system busy


at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:823)
at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:756)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:673)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1400)
... 3 more



顶部