1. 程式人生 > >SMTPSendFailedException: 554 DT:SPM 163問題解決

SMTPSendFailedException: 554 DT:SPM 163問題解決

今天測試springboot自帶郵件的外掛,用剛生成的163校驗碼,配置了一下環境,具體程式碼實現如下
程式碼實現

  @Autowired
    private JavaMailSenderImpl javaMailSender;
    
    @Override
    public void sendMail(String title,String content){
        SimpleMailMessage message = new SimpleMailMessage();
        message.setSubject(title);
        message.
setText(content); message.setFrom("[email protected]"); message.setTo("[email protected]"); javaMailSender.send(message); }

properties檔案裡面的配置如下

#郵件配置
spring.mail.username=***@163.com
# 這裡使用授權碼
spring.mail.password=*******
spring.mail.host=smtp.163.com
spring.
mail.protocol=smtp spring.mail.properties.mail.smtp.ssl.enable=true
    @Test
    public void hello(){
       helloController.sendMail("測試","郵件測試。。。");
    }

然後跑測試類的時候報錯了554,如下圖

com.sun.mail.smtp.SMTPSendFailedException: 554 DT:SPM 163 smtp8,DMCowAAHykA10wBcJuyiCg--.59524S2 1543557942,please see http://mail.163.com/help/help_spam_16.htm?ip=58.32.8.46&hostid=smtp8&time=1543557942

	at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2358)
	at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:2110)
	at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1316)
	at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:462)
	at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:321)
	at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:310)
	at com.hm.service.impl.HelloServiceImpl.sendMail(HelloServiceImpl.java:42)
	at com.hm.controller.HelloController.sendMail(HelloController.java:84)
	at com.hm.controller.HelloController$$FastClassBySpringCGLIB$$927db678.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)

然後根據提示查看了http://mail.163.com/help/help_spam_16.htm?ip=58.32.8.46&hostid=smtp8&time=1543557942的資訊,發現554

•554 DT:SPM 傳送的郵件內容包含了未被許可的資訊,或被系統識別為垃圾郵件。請檢查是否有使用者傳送病毒或者垃圾郵件;

然後我看了下自己的備註發現並沒有包含什麼敏感資訊,接著換一個賬號這個賬號之前註冊過,不是當天的申請的授權碼,

所以這個問題等到第二天再試下,應該就可以了