关于Hutool发送邮件
时间:2019-11-07 15:49:53
收藏:0
阅读:677
最近需要发送邮件,就找到Hutool工具来,感觉比较方便,可是在看案例的时候,都按照案例来的,一直报错。我用的是126邮箱来的。
Exception in thread "main" cn.hutool.extra.mail.MailException: AuthenticationFailedException: 535 Error: authentication failed
源码是这样的
MailAccount account = new MailAccount(); account.setHost("smtp.126.com"); account.setPort(25); account.setAuth(true); account.setFrom("mikemhm@126.com"); account.setUser("mikemhm"); //密码(注意不是登录密码,是网易客户端登录授权码) account.setPass("12345**"); MailUtil.send(account,CollUtil.newArrayList("bicc499@163.com"), "测试", "邮件来自Hutool测试", false);
一开始我用的密码都是登录密码,一直显示验证错误,后来改成了授权码,终于发送成功了。

原文:https://www.cnblogs.com/mikemhm/p/11811647.html
评论(0)