问题描述
邮件发送功能一直发送失败,报错日志:
Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 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.
解决方案
身份验证失败,TLS证书版本低,让升级到1.2版本,添加邮箱参数配置:“mail.smtp.ssl.protocols” ===》 “TLSv1.2”:
Properties javaMailProperties = new Properties();
javaMailProperties.setProperty("mail.smtp.auth", "true");
javaMailProperties.setProperty("mail.smtp.timeout", "25000");
javaMailProperties.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
javaMailProperties.setProperty("mail.smtp.ssl.protocols", "TLSv1.2"); //设置使用TLS1.2版本
文章讲述了在邮件发送功能中遇到的身份验证失败问题,原因在于TLS证书版本过低,解决方案是将邮件客户端的TLS协议升级至1.2版本,并提供了JavaMailProperties中相应的配置示例。
2786





