程序员的资源宝库

网站首页 > gitee 正文

关于Hutool发送邮件

sanyeah 2024-04-12 17:39:49 gitee 8 ℃ 0 评论

最近需要发送邮件,就找到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);

一开始我用的密码都是登录密码,一直显示验证错误,后来改成了授权码,终于发送成功了。

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表