spring - Spring Mail 身份验证失败
问题描述
我正在尝试使用 spring boot mail api 发送电子邮件。这是我的代码
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost("smtp.gmail.com");
mailSender.setPort(587);
mailSender.setUsername("xxx@gmail.com");
mailSender.setPassword("xxx");
Properties props = mailSender.getJavaMailProperties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.debug", "true");
return mailSender;
但它不发送电子邮件,这是日志:
DEBUG: Using mechanism LOGIN
DEBUG SMTP: AUTH LOGIN command trace suppressed
DEBUG SMTP: AUTH LOGIN failed
解决方案
Everything was correct and the problem was about connecting to google, I didn't figure out why but it solved itself and now I can send email.
推荐阅读
- awk - 如果字符不在线,则 awk 匹配模式
- python - Scrapy:是否可以使用验证码进行scrapy?
- python - 无法启动 Spyder 版本 4.1.1
- r - 我无法使用 as.POSIXct 将具有 UTC 偏移量的字符串转换为 R 中的日期
- asp.net-mvc - 如何在 MVC Razor 视图中进行 AJAX 调用?
- python - 在 Python 中计算 RSI 以进行 BTC 交易回测
- sql - 用 Oracle 替换多个字符
- scala - Scala 隐式优先级系统
- android - 底部导航视图中加载的片段在方向更改时变为空
- python - PyQt5 - 无法根据 QDialog 接受的信号调用函数