1

我使用 JavaMail 1.4.3 版,我可以在我的开发环境中发送电子邮件,但在 ubuntu 服务器中部署时无法发送电子邮件。我比较调试日志如下:不能接受smtp,但我的本地可以。有什么建议吗?我也在这里搜索java邮件错误

local:

    **DEBUG: setDebug: JavaMail version 1.4.3
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.gmail.com", port 465, isSSL false
220 mx.google.com ESMTP u9sm646165paf.22 - gsmtp
DEBUG SMTP: connected to host "smtp.gmail.com", port: 465
EHLO 10.37.129.2
250-mx.google.com at your service, [112.64.93.195]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH XOAUTH2
250 ENHANCEDSTATUSCODES
DEBUG SMTP: Found extension "SIZE", arg "35882577"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XOAUTH XOAUTH2"
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Attempt to authenticate
DEBUG SMTP: check mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM 



ubuntu:

DEBUG: setDebug: JavaMail version 1.4.3
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.gmail.com", port 465, isSSL false
220 mx.google.com ESMTP ed8sm502698qeb.7 - gsmtp
DEBUG SMTP: connected to host "smtp.gmail.com", port: 465


WkFRITJ3c3hjZGUz
535-5.7.1 Username and Password not accepted. Learn more at
535 5.7.1 http://support.google.com/mail/bin/answer.py?answer=14257 ed8sm502698qeb.7 - gsmtp
15:21:33,167 ERROR ~

@6e0gki7nd
The email has not been sent

Mail error
A mail error occured : Error while sending email

play.exceptions.MailException: Error while sending email
        at play.libs.Mail$2.call(Mail.java:186)
        at play.libs.Mail$2.call(Mail.java:178)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)
Caused by: org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:25
        at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1242)
        at org.apache.commons.mail.Email.send(Email.java:1267)
        at play.libs.Mail$2.call(Mail.java:183)
        ... 6 more
Caused by: javax.mail.AuthenticationFailedException: 535-5.7.1 Username and Password not accepted. Learn more at
535 5.7.1 http://support.google.com/mail/bin/answer.py?answer=14257 ed8sm502698qeb.7 - gsmtp

        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 javax.mail.Service.connect(Service.java:121)
        at javax.mail.Transport.send0(Transport.java:190)
        at javax.mail.Transport.send(Transport.java:120)
        at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1232)
        ... 8 more
4

1 回答 1

0

最可能的解释是您认为在这两种情况下都使用相同的用户名和密码,但事实并非如此。

请注意,“AUTH LOGIN”之后的有趣文字是您的 base64 编码的用户名和密码。任何人都可以解码它们。如果不解码它们,我可以告诉您它们在两种情况下都不相同,可能是因为您以某种方式更改了调试输出。

检查您的程序并确保您在两种情况下都使用相同的用户名和密码。

于 2013-04-11T03:49:41.430 回答