JAVA

Java Office365 SMTP 메일발송 실패

쿠카이든 2023. 10. 23. 17:43
728x90
javax.mail.AuthenticationFailedException 에러를 발생하며 메일발송이 실패

  • javax.mail.Session의 setDebug(true)로 디버깅 결과

 

  • 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");                   //true 앞뒤에 쌍따옴표를 꼭 넣어야한다!!
props.put("mail.smtp.starttls.enable", "true");		   //true 앞뒤에 쌍따옴표를 꼭 넣어야한다!!
props.put("mail.smtp.port", 587);
// 해당 코드 추가
props.put("mail.smtp.ssl.protocols", "TLSv1.2");
728x90