【发布时间】:2017-07-20 23:44:09
【问题描述】:
以下是office 365邮箱账号发送邮件的流程码:
收到的异常是:
com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM
相同的帐户、凭据、主机、端口在 groovy 脚本中工作:
public static void simpleMail(String from, String password, String to,
String subject, String body) throws Exception {
String host = "smtp.office365.com";
Properties props = System.getProperties();
props.put("mail.smtp.starttls.enable",true);
props.setProperty("mail.smtp.ssl.trust", host);
props.put("mail.smtp.auth", true);
props.put("mail.smtp.host", host);
props.put("mail.smtp.user", from);
props.put("mail.smtp.password", password);
props.put("mail.smtp.port", "587");
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
InternetAddress toAddress = new InternetAddress(to);
message.addRecipient(Message.RecipientType.TO, toAddress);
message.setSubject(subject);
message.setText(body);
Transport transport = session.getTransport("smtp");
transport.connect(host, from, password);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
System.out.println("Mail Sent Successfully");
}
看起来 groovy 脚本有“mail.smtp.starttls.enable”:是的, "mail.smtp.ssl.trust" : 脚本代码中的主机名作为属性添加在其中。
那么我如何在 mule 中使用 SMTP 连接器来反映这一点?
任何建议都会很棒。
【问题讨论】:
-
下面是我使用的 Mule 代码:“
异常:SMTPSendFailedException 客户端在 MAIL FROM 期间未通过身份验证发送匿名邮件 -
您好,欢迎来到 StackOverflow!我建议您宁愿搜索您的错误消息,将其粘贴到 Google 中,并且 StackOverflow 上至少有几个问题 - 检查是否有任何帮助。
-
嗨,谢谢,但没有找到关于我上述问题的任何参考资料。
-
如何在 mule 中为 SMTP 连接器启用 starttls ?
标签: groovy smtp mule office365 starttls