Dev_Log

[Java] office365 SMTP 메일발송 실패

LeeDaniel 2022. 3. 18. 14:56
-잘되던 office365를 통한 SMTP 메일발송이
javax.mail.AuthenticationFailedException 에러를 발생하며 메일발송이 실패
javax.mail.AuthenticationFailedException 발생

(메일 계정,비밀번호는 문제없는상태)

javax.mail.Session의 setDebug(true)로 디버깅 결과
SMTP 메일발송 실패

421 4.7.66 TLS 1.0 and 1.1 are not supported. Please upgrade/update your client to support TLS 1.2. Visit https://aka.ms/smtp_auth_tls. [SL2P216CA0101.KORP216.PROD.OUTLOOK.COM]
DEBUG: setDebug: JavaMail version 1.4.1ea-SNAPSHOT
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.office365.com", port 25, isSSL false
220 SL2P216CA0099.outlook.office365.com Microsoft ESMTP MAIL Service ready at Fri, 18 Mar 2022 04:30:00 +0000
DEBUG SMTP: connected to host "smtp.office365.com", port: 25
에러 발생

✔ Solution
https://aka.ms/smtp_auth_tls에  접속을 해보면

New submission error speedbump to be introduced

We are fully aware that many customers will not have noticed the multiple Message Center posts and blog posts, and are not aware of clients or devices that are still using TLS1.0 to submit messages. With this in mind, starting in September 2021, we will reject a small percentage of connections that use TLS1.0 for SMTP AUTH. Clients should retry as with any other temporary errors that can occur during submission. Over time we will increase the percentage of rejected connections, causing delays in sending that more and more customers should notice. The error will be:

421 4.7.66 TLS 1.0 and 1.1 are not supported. Please upgrade/update your client to support TLS 1.2. Visit https://aka.ms/smtp_auth_tls.

We intend to make a final announcement when we are ready to make the change to disable TLS1.0 and TLS1.1 for SMTP AUTH for the regular endpoint.

를 확인할 수 있다

따라서
props.put("mail.smtp.ssl.protocols", "TLSv1.2");를 추가해주면 된다

Properties props = new Properties();
props.put("mail.smtp.host", "smtp.office365.com");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.port", 587);
// 해당 코드 추가
props.put("mail.smtp.ssl.protocols", "TLSv1.2");

 

 

 

반응형