繁体   English   中英

如何使用带有 Office 365 邮箱的 Mule SMTP 连接器发送电子邮件? 另外如何在 Mule 中使用 SMTPS?

[英]how to use Mule SMTP connector with office 365 mailbox to send email ? Also how to use SMTPS in Mule?

以下是用于从 Office 365 邮件帐户发送邮件的流程代码:

收到的异常是: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM 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”:true,“mail.smtp.ssl.trust”:脚本代码中的主机名作为添加到其中的属性。

那么我如何在 mule 中使用 SMTP 连接器来反映这一点呢?

任何建议都会很棒。

要为 SMTP 连接器启用 starttls,打开电子邮件连接器,单击高级选项卡,单击属性并选择内联,然后添加键:“mail.smtp.starttls.enable”并设置值 = true。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM