簡體   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