文章目录
方式一
1.配置文件 mail.setting
:
# 邮件服务器的SMTP地址,可选,默认为smtp.<发件人邮箱后缀>
host = smtp.qq.com
# 邮件服务器的SMTP端口,可选,默认25
port = 587
# 发件人(必须正确,否则发送失败)
from = 422615924@qq.com
# 用户名,默认为发件人邮箱前缀
user = 422615924
# 密码(注意,某些邮箱需要为SMTP服务单独设置授权码,详情查看相关帮助)
pass = *****
2.发送:
MailUtil.send(email, "测试", "三战后台登陆码: " + code, false);
方式二
MailAccount account = new MailAccount();
account.setHost("smtp.qq.com");
account.setPort(587);
account.setAuth(true);
account.setFrom(email);
account.setUser(email);
account.setPass(admin.qqEmailPass);
MailUtil.send(account, email, "三战后台登录短信码", code, false);
[1] Hutool
[2] java工具类hutool发送QQ邮件