一、问题描述
在使用Javamai进行邮件发送时遇到的坑。发出邮箱需要填写账户和
授权码
而不是密码。
在程序中通过qq邮件服务器发送邮件时,尽管用户名、密码正确但仍然报错
javax.mail.AuthenticationFailedException: 535 Login Fail. Please enter your authorization code to login. More information in
- 原因:没有在QQ邮箱中开启相应服务(设置了QQ邮箱锁)。
二、解决方法
在QQ邮箱中开启服务(如POP3/SMTP服务),生成
授权码
,并将密码更换为授权码。
2.1开启服务
- 登陆到发送邮件的QQ邮箱,进入 [设置]-->[账户] 页面。
- 在该页面中找到 POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务,将
POP3/SMTP服务
和IMAP/SMTP服务
两个服务开启。
2.2生成授权码
- 发送短信认证获取授权码
- 将如下生成的授权码替换为发送账号的密码即可