文章目录


问题描述

邮件发送功能一直发送失败,报错日志:

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版本
        
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐