javamail 发送邮件 Authentication failed

林小米 发布于 2012/04/25 13:29
阅读 8K+
收藏 0

本地与服务器环境一模一样

本地测试邮件发送都成功,

但服务器就出现下面错误

度娘了下 说权限帐号等问题 都检测过不存在


org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:416) at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:342) at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:338) at com.gs.task.TargetObject.sendMsg(TargetObject.java:187) at com.gs.task.TargetObject.autoSendMail(TargetObject.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:275) at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:272) at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529) Caused by: javax.mail.AuthenticationFailedException at javax.mail.Service.connect(Service.java:264) at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:389)

加载中
0
杨延庆
杨延庆
邮件服务器在本机还是远程?
林小米
林小米
远程
0
小黑小别姬
小黑小别姬
肯定不一样 我是来呵呵的
0
Andre.Z
Andre.Z
服务器上有防火墙的没?一般服务器上端口都限制了,只有需要的时候才开。查一下是不是应用服务器连邮件服务器的端口被禁了啊。端口被禁用,请求都发不出去,当然验证失败。
林小米
林小米
防火墙关掉了,端口也打开了
0
林小米
林小米
使用 outlook 等软件 可以正常发送邮件··
红薯
红薯
outlook 是微软的,hotmail也是微软的,当然可以啦:)
0
林小米
林小米

自己又手动写了段 javamail 的邮件测试··

在其他的服务器(都是远程)都可以正常发送

就这台不同。

于是我再找不同点·· 就发现最大的不同就是这台机子是双线双IP的··其他的机子都是单线的

其他的java环境基本一致··

很郁闷的问,这个有关系么 双线双IP...

0
林小米
林小米

成功的服务器

DEBUG: setDebug: JavaMail version 1.3.2
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.exmail.sina.com", port 25, isSSL false
220 mail228.exmail.sina.com ESMTP
DEBUG SMTP: connected to host "smtp.exmail.sina.com", port: 25

EHLO 52hualin-427298
250-mail228.exmail.sina.com
250-8BITMIME
250-SIZE 83886080
250-STARTTLS
250-AUTH PLAIN LOGIN
250 AUTH=PLAIN LOGIN
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "SIZE", arg "83886080"
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "AUTH", arg "PLAIN LOGIN"
DEBUG SMTP: Found extension "AUTH=PLAIN", arg "LOGIN"
DEBUG SMTP: Attempt to authenticate
AUTH LOGIN
334 VXNlcm5hbWU6
YW1pQHh1YW5zaGFuZ3Bpbi5jb20=
334 UGFzc3dvcmQ6
YW1pQHhzcDIwMTE=
235 #2.0.0 OK Authenticated
DEBUG SMTP: use8bit false
MAIL FROM:<ami@xuanshangpin.com>
250 sender <ami@xuanshangpin.com> ok
RCPT TO:<amily4555@126.com>
250 recipient <amily4555@126.com> ok
DEBUG SMTP: Verified Addresses
DEBUG SMTP:   amily4555@126.com
DATA
354 go ahead
Message-ID: <13743917.1335400972265.JavaMail.Administrator@52hualin-427298>
From: ami@xuanshangpin.com
To: amily4555@126.com
Subject: I love you
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I love u so long
.
250 ok:  Message 77927182 accepted
QUIT

失败的..服务器

DEBUG: setDebug: JavaMail version 1.3.2
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.exmail.sina.com", port 25, isSSL false
220 mail125.exmail.sina.com ESMTP
DEBUG SMTP: connected to host "smtp.exmail.sina.com", port: 25

EHLO servers-host

250-mail125.exmail.sina.com
250-8BITMIME
250-SIZE 83886080
250-STARTTLS
250-AUTH PLAIN LOGIN
250 AUTH=PLAIN LOGIN
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "SIZE", arg "83886080"
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "AUTH", arg "PLAIN LOGIN"
DEBUG SMTP: Found extension "AUTH=PLAIN", arg "LOGIN"
DEBUG SMTP: Attempt to authenticate
AUTH LOGIN
500 #5.5.1 command not recognized
javax.mail.AuthenticationFailedException
	at javax.mail.Service.connect(Service.java:264)
	at javax.mail.Service.connect(Service.java:134)
	at javax.mail.Service.connect(Service.java:86)
	at com.sun.mail.smtp.SMTPTransport.connect(SMTPTransport.java:144)
	at javax.mail.Transport.send0(Transport.java:150)
	at javax.mail.Transport.send(Transport.java:80)
	at jms.EmailTest.testFindUserWithPg(EmailTest.java:59)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at junit.framework.TestCase.runTest(TestCase.java:164)
	at junit.framework.TestCase.runBare(TestCase.java:130)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:120)
	at junit.framework.TestSuite.runTest(TestSuite.java:230)
	at junit.framework.TestSuite.run(TestSuite.java:225)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


0
杨延庆
杨延庆
你能改成单ip试试么?
林小米
林小米
3个月后 系统没任何改变,设置也无改变,重新打开邮件功能,就忽然可以用了,于是我忍,我接受
0
杨延庆
杨延庆
我觉得你可以考虑换一个邮件服务器了
返回顶部
顶部