有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

javajavax。由于javax,邮件“535.7.3身份验证失败”。邮件升级(v1.3.1至v1.5.2)

1.问题

我公司的一位客户即将升级我们软件的版本。在升级的测试环境中,他发现自己无法再通过应用程序发送邮件(他没有更改SMTP服务器的配置,这与他在一切正常的生产环境中使用的配置相同)

我们通过测试发现,这个“bug”是由改变javax的升级引起的。邮件jar从1.3.1版到1.5.2版。为了验证这一点,我们给了客户一个。类来执行哪个发送电子邮件,以及它是否使用javax的1.3.1版本。mail jar可以工作,但如果它使用1.5.2版本,则无法工作。客户端将服务器配置写入属性文件

服务器配置

mail.smtp.host=<ip_adress>
mail.smtp.port=25

mail.from=clientCompany@clientDomain
mail.to=recipient@clientDomain

mail.smtp.user=clientCompany@clientDomain
mail.smtp.password=<client_pwd>

mail.subject=whatever
mail.body=whatever

Java(轻版)

Properties systemProperties = System.getProperties();
systemProperties.putAll(fileProperties);
Session mailSession = Session.getDefaultInstance(systemProperties);
Transport tr = mailSession.getTransport("smtp");
tr.connect(mailSmtpHost, Integer.valueOf(mailSmtpPort), mailSmtpUser, mailSmtpPassword);
tr.sendMessage(mailToSend, mailToSend.getAllRecipients());

日志(如果javax.mail 1.5.2)

DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
...
DEBUG SMTP: trying to connect to host "<ip_adress>", port 25, isSSL false
...
DEBUG SMTP: connected to host "<ip_adress>", port: 25
...
DEBUG SMTP: Found extension "SIZE", arg "37748736"
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "X-ANONYMOUSTLS", arg ""
DEBUG SMTP: Found extension "AUTH", arg "NTLM"
DEBUG SMTP: Found extension "X-EXPS", arg "GSSAPI NTLM"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: Found extension "XRDST", arg ""
DEBUG SMTP: Attempt to authenticate using mechanisms: NTLM
DEBUG NTLM: type 1 message: 4E 54 4C 4D 53 53 50 00 01 00 00 00 03 B2 00 00 0A 00 0A 00 2E 00 00 00 0E 00 0E 00 20 00 00 00 50 42 54 4B 41 50 4D 4F 42 49 4C 45 30 31 42 54 4B 44 2E 4C 4F 43 41 4C
DEBUG SMTP: AUTH NTLM command trace suppressed
DEBUG NTLM: type 3 message: 4E 54 4C 4D 53 53 50 00 03 00 00 00 18 00 18 00 9E 00 00 00 18 00 18 00 B6 00 00 00 14 00 14 00 40 00 00 00 2E 00 2E 00 54 00 00 00 1C 00 1C 00 82 00 00 00 00 00 00 00 CE 00 00 00 01 82 00 00 42 00 54 00 4B 00 44 00 2E 00 4C 00 4F 00 43 00 41 00 4C 00 65 00 62 00 61 00 6E 00 6B 00 69 00 6E 00 67 00 2D 00 62 00 74 00 6B 00 40 00 62 00 74 00 6B 00 6E 00 65 00 74 00 2E 00 63 00 6F 00 6D 00 50 00 42 00 54 00 4B 00 41 00 50 00 4D 00 4F 00 42 00 49 00 4C 00 45 00 30 00 31 00 1F F4 4F 84 82 68 AD 69 9E D3 84 53 11 98 FE 72 78 06 75 79 03 E4 04 6F A5 F5 FA E5 F7 B0 E5 98 CD 25 20 B5 10 04 B9 64 B5 A8 2E 2F D9 C5 64 B7
DEBUG SMTP: AUTH NTLM failed
javax.mail.AuthenticationFailedException: 535 5.7.3 Authentication unsuccessful
at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:892)
at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:814)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:728)
at javax.mail.Service.connect(Service.java:364)
at MailSendTest.sendMail(MailSendTest.java:87)
at MailSendTest.main(MailSendTest.java:132)

日志(如果javax.mail 1.3.1)

DEBUG: java.io.FileNotFoundException: /opt/java64/jdk1.6.0_30/jre/lib/javamail.providers (No such file or directory)
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.address.map
DEBUG: java.io.FileNotFoundException: /opt/java64/jdk1.6.0_30/jre/lib/javamail.address.map (No such file or directory)
...
DEBUG SMTP: trying to connect to host "<ip_adress>", port 25
...
DEBUG SMTP: connected to host "<ip_adress>", port: 25
...
DEBUG SMTP: Found extension "SIZE", arg "37748736"
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "X-ANONYMOUSTLS", arg ""
DEBUG SMTP: Found extension "AUTH", arg "NTLM"
DEBUG SMTP: Found extension "X-EXPS", arg "GSSAPI NTLM"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: Found extension "XRDST", arg ""
DEBUG SMTP: Attempt to authenticate
DEBUG SMTP: use8bit false
MAIL FROM:<clientCompany@clientDomain>
250 2.1.0 Sender OK
RCPT TO:<recipient@clientDomain>
250 2.1.5 Recipient OK
DEBUG SMTP: Verified Addresses
DEBUG SMTP:   recipient@clientDomain
DATA
354 Start mail input; end with <CRLF>.<CRLF>
Message-ID: <181398600.1528806707522.JavaMail.clientCompany@clientDomain>
From: clientCompany@clientDomain
To: recipient@clientDomain
Subject: whatever
Mime-Version: 1.0
Content-Type: multipart/mixed;
        boundary="----=_Part_0_1199604121.1528806707440"

------=_Part_0_1199604121.1528806707440
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

whatever
------=_Part_0_1199604121.1528806707440--

2.解决方案

当我尝试使用。用javax初始化。邮件1.5.2和我公司的SMTP服务器配置,可以正常工作。我无法重现他们的错误。所以我们猜测它可能来自他们的邮件服务器

我读了很多关于这个问题的话题,但还没有找到任何解决方案。可能正在将端口从25更改为587,这是推荐的端口,但我真的不明白为什么它会改变任何东西(而且它在我的计算机上与25或587一起工作)


共 (0) 个答案