javax.mail.AuthenticationFailedException: 530 Login fail. A secure connection is requiered(such as ssl). More information at https://help.mail.qq.com/detail/0/1010
解决方法在代码中加入 开启 加密的设置。 原代码 - Properties props = System.getProperties();
- // 设置SMTP服务器地址
- props.put("mail.smtp.host", host);
- // 设置服务器验证
- props.put("mail.smtp.auth", "true");
- // 设置传输协议
- props.put("mail.transport.protocol", "smtp");
-
- MailAuthenticator auth = new MailAuthenticator(user, password);
复制代码修改后的代码
- Properties props = System.getProperties();
- // 设置SMTP服务器地址
- props.put("mail.smtp.host", host);
- // 设置服务器验证
- props.put("mail.smtp.auth", "true");
- // 设置传输协议
- props.put("mail.transport.protocol", "smtp");
- props.put("mail.smtp.socketFactory.port", "465"); // SSL端口号通常为465
- props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); // 使用SSL套接字工厂
-
- MailAuthenticator auth = new MailAuthenticator(user, password);
复制代码实操案例:邮箱发送功能 5,SpringBoot 3.5.11实操小功能开发【邮箱email发送功能】
|