简体   繁体   English

Spring Boot 邮件发件人错误:com.sun.mail.smtp.SMTPSendFailedException

[英]Error at Spring Boot mail sender: com.sun.mail.smtp.SMTPSendFailedException

I want to create a mail sender in a spring boot application.我想在 Spring Boot 应用程序中创建一个邮件发件人。 here is my configuration and the code of mail sender这是我的配置和邮件发件人的代码

application.properties :应用程序属性:

spring.mail.host=smtp.office365.com
spring.mail.username=********@outlook.com
spring.mail.password=********
spring.mail.port=587 
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.required=true

mail sender code :邮件发件人代码:

@Service
public class EmailSender {


    @Autowired 
    private  JavaMailSender javaMailSender; 

    public  void send ( String to , String subject , String body ) throws MessagingException {


        MimeMessage message = javaMailSender.createMimeMessage() ; 
        MimeMessageHelper helper ; 
        helper = new    MimeMessageHelper(message , true ) ;  
        helper.setSubject(subject);
        helper.setTo(to); 
        helper.setText(body ,true ); 
        javaMailSender.send(message);


    }

}

When i called the send method i had the following exception in the stacktrace :当我调用 send 方法时,堆栈跟踪中出现以下异常:

org.springframework.mail.MailSendException: Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 16.55847:EE030000, 17.43559:0000000094000000000000000000000000000000, 20.52176:140FC28611004010F1030000, 20.50032:140FC28683174010F1030000, 0.35180:3D100000, 255.23226:00000000, 255.27962:0A000000, 255.27962:0E000000, 255.31418:140FC286, 16.55847:8C000000, 17.43559:0000000070010000000000000100000000000000, 20.52176:140FC2861100F01F0A000000, 20.50032:140FC28683170011810F0000, 0.35180:00000000, 255.23226:00000000, 255.27962:0A000000, 255.27962:32000000, 255.17082:DC040000, 0.27745:140FC286, 4.21921:DC040000, 255.27962:FA000000, 255.1494:64000000, 0.38698:00000000, 0.37692:05000780, 0.37948:1A010480, 5.33852:00000000534D545000000100, 4.56248:DC040000, 7.40748:010000000000010B05000780, 7.57132:000000000000000000000000, 1.63016:32000000, 4.39640:DC040000, 8.45434:014003006018492000000000000000001A010480, 5.10786:0000000031352E32302E313733302E3031373A564931505231304D42313930333A36356263666132632D336133352D343030662D616665622D34306239353462656436373500503000000000, 255.1750:A0000000, 255.31418:0A005636, 0.22753:A5000000, 255.21817:DC040000, 4.60547:DC040000, 0.21966:03003866, 4.30158:DC040000 [Hostname=VI1PR10MB1903.EURPRD10.PROD.OUTLOOK.COM]

您应该将 From-header 设置为您的用户名。

暂无
暂无

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

相关问题 com.sun.mail.smtp.SMTPSendFailedException Javamail - com.sun.mail.smtp.SMTPSendFailedException Javamail com.sun.mail.smtp.SMTPSendFailedException: 550 5.2.125 发件人已超过允许发送的最大邮件数 - com.sun.mail.smtp.SMTPSendFailedException: 550 5.2.125 The sender has exceeded the maximum number of messages they are allowed to send com.sun.mail.smtp.SMTPSendFailedException:553抱歉,您的信封发件人在我的badmailfrom列表中 - com.sun.mail.smtp.SMTPSendFailedException: 553 Sorry, your envelope sender is in my badmailfrom list MailSendException:失败的消息:com.sun.mail.smtp.SMTPSendFailedException - MailSendException: Failed messages: com.sun.mail.smtp.SMTPSendFailedException com.sun.mail.smtp.SMTPSendFailedException:530 5.7.1客户端未通过身份验证 - com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.1 Client was not authenticated 如何解决com.sun.mail.smtp.SMTPSendFailedException在Java中? - how to solve com.sun.mail.smtp.SMTPSendFailedException in java ? 错误:com.sun.mail.smtp.SMTPSendFailedException:451 4.3.0 错误:队列文件写入错误 - Error: com.sun.mail.smtp.SMTPSendFailedException: 451 4.3.0 Error: queue file write error com.sun.mail.smtp.SMTPSendFailedException:530-5.5.1需要身份验证(Java Mail) - com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required (Java Mail) com.sun.mail.smtp.SMTPSendFailedException:530 5.7.0必须首先发出STARTTLS命令 - com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 需要身份验证 - com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM