javax.mail.AuthenticationFailedException: 535 authentication failed

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cuiyaoqiang/article/details/50392937

Exception in thread “main” javax.mail.AuthenticationFailedException: 535 Error: authentication failed

at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:648)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:583)
at javax.mail.Service.connect(Service.java:313)
at javax.mail.Service.connect(Service.java:172)
at com.bh.mail.MailSender.main(MailSender.java:30)

这个是验证没通过,需要检查一下以下几点:
1、你的用户名和密码是否正确
2、你的邮箱服务是否是你的的发送邮箱
例如:你的邮箱服务为:smtp.163.com,而你的发送邮箱就必须是xxxx@163.com;接收邮箱随便。

展开阅读全文

javax.mail.AuthenticationFailedException: 535 Error: authentication failed

11-05

1、测试代码:rn[code=java]rnimport java.io.IOException;rnrnimport javax.mail.MessagingException;rnimport javax.mail.Session;rnrnimport org.junit.Test;rnrnimport cn.itcast.mail.Mail;rnimport cn.itcast.mail.MailUtils;rnrn/**rn * 测试MailUtils,作用是发邮件rn * 底层依赖的是javamail:mail.jar、activation.jarrn * @author miaoxingrenrn *rn */rnpublic class MailUtilsTest rn /**rn * 发邮件rn * @throws IOException rn * @throws MessagingException rn */rn @Testrn public void sent() throws MessagingException, IOExceptionrn /*rn * 1.登录邮件服务器rn * MailUtils.createSession(服务器地址,登录名,密码);rn * 2.创建邮件对象rn * 发件人rn * 收件人rn * 主题rn * 正文rn * 3.发rn * 需要第一步得到session、和第二步的邮件对象rn */rn Session session = MailUtils.createSession("smtp.163.com", "xxx", "xxx");rn rn Mail mail = new Mail("xxx1@163.com", "xxx2@163.com", "测试邮件一封", "百度");rn rn MailUtils.send(session, mail);rn rnrn[/code]rn2、使用的jar包情况:[img=https://img-bbs.csdn.net/upload/201511/05/1446719380_851279.png][/img]rnrn3、出现的异常信息:rnjavax.mail.AuthenticationFailedException: 535 Error: authentication failedrnrn at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:648)rn at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:583)rn at javax.mail.Service.connect(Service.java:313)rn at javax.mail.Service.connect(Service.java:172)rn at javax.mail.Service.connect(Service.java:121)rn at javax.mail.Transport.send0(Transport.java:190)rn at javax.mail.Transport.send(Transport.java:120)rn at cn.itcast.mail.MailUtils.send(MailUtils.java:91)rn at MailUtilsTest.sent(MailUtilsTest.java:42)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)rn at java.lang.reflect.Method.invoke(Method.java:601)rn at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)rn at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)rn at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)rn at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)rn at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)rn at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)rn at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)rn at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)rn at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)rn at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)rn at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)rn at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)rn at org.junit.runners.ParentRunner.run(ParentRunner.java:236)rn at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)rn at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)rnrn4、注:①邮箱的账号密码都正确,并且开启了SMTP协议rn ②试过底层删除mail和activation文件夹,方法无效rn ③目前使用的是另一种解决办法:将Java EE 5 Library 改为6的 上述出现的异常就是这种办法的rnrn查了很久,还是没解决,希望哪位大神帮忙看看,帮我这个菜鸟解决下,好人一生平安,谢谢!rnrnrnrnrnrnrn 论坛

没有更多推荐了,返回首页