java调用邮箱报错解决: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

错误信息:

com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM [HK0PR03CA0038.apcprd03.prod.outlook.com]

    at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2108)
    at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1609)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1117)
    at javax.mail.Transport.send0(Transport.java:254)
    at javax.mail.Transport.send(Transport.java:124)

maven依赖:

        
        
            javax.mail
            mail
            1.4.7
        

配置信息如下

            Properties pro = System.getProperties();
            pro.put("mail.smtp.host", host);
            pro.put("mail.smtp.port", port);
            pro.put("mail.smtp.auth", "true");

增加 pro.put("mail.smtp.starttls.enable", "true");

            pro.put("mail.smtp.host", host);
            pro.put("mail.smtp.port", port);
            pro.put("mail.smtp.auth", "true");
            pro.put("mail.smtp.starttls.enable", "true");

发送成功。

 

感谢https://blog.csdn.net/sinat_33324214/article/details/52910186

你可能感兴趣的:(java)