雅虎 SMTP 连接超时

问题描述

我的应用程序中有一段代码,它使用 Yahoo 作为邮件中继发送电子邮件。 该代码几个月以来一直运行良好,但在过去几个月中,我在尝试发送电子邮件时收到“连接超时”。 这段代码是用 Java 编写的,并使用了 SMTP。

这段代码适用于 GMail。使用 GMail 作为邮件提供商的问题是 Google 包含在该服务中的一系列烦恼(不太安全的应用程序激活、浏览器登录、验证码取消......)。

有什么想法吗?提前致谢。

Properties props = System.getProperties();
props.put("mail.smtp.host",SMTP);
props.put("mail.smtp.port","587");
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.auth","true");

Session session = Session.getInstance(props,new Authenticator() {
    protected PasswordAuthentication getpasswordAuthentication() {
        return new PasswordAuthentication(USER,PASS);
    }
});

session.setDebug(true);
MimeMessage mm = new MimeMessage(session);
mm.setSubject(subject);
mm.setFrom(USER);

for (String recipient : recipients) {
    mm.addRecipients(Message.RecipientType.BCC,InternetAddress.parse(recipient,false));
}

mm.setSentDate(new Date());
mm.setContent(message,"text/HTML; charset=UTF-8");         

Transport.send(mm);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)