title: javax.mail - "535 5.7.3 Authentication unsuccessful" due to javax.mail upgrade (v1.3.1 to v1.5.2)
body: <h1>1 - Problem</h1>
  
  <p>A client of my company is about to upgrade the version of our software. In his test environment for the upgrade, he discovered that he cannot a send mail through the application anymore (he didn't change the configuration of his SMTP server, which is the same he uses for his production environment where everything is fine). </p>
  
  <p><strong>We figured out with a test that this "bug" is caused by the upgrade which changes the javax.mail jar from version 1.3.1 to version 1.5.2</strong>. To verify this, we gave the client a .class to execute which send an email, and if it uses the 1.3.1 version of the javax.mail jar, it works, but if it uses the 1.5.2 version, it does not work. The client writes the server configuration in a property file.</p>
  
  <h3>Server configuration</h3>
  
  <pre><code>mail.smtp.host=&lt;ip_adress&gt;
  mail.smtp.port=25
  
  mail.from=clientCompany@clientDomain
  mail.to=recipient@clientDomain
  
  mail.smtp.user=clientCompany@clientDomain
  mail.smtp.password=&lt;client_pwd&gt;
  
  mail.subject=whatever
  mail.body=whatever
  </code></pre>
  
  <h3>Java (light version)</h3>
  
  <pre><code>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());
  </code></pre>
  
  <h3>Log (if javax.mail 1.5.2)</h3>
  
  <pre><code>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 "&lt;ip_adress&gt;", port 25, isSSL false
  ...
  DEBUG SMTP: connected to host "&lt;ip_adress&gt;", 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)
  </code></pre>
  
  <h3>Log (if javax.mail 1.3.1)</h3>
  
  <pre><code>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 "&lt;ip_adress&gt;", port 25
  ...
  DEBUG SMTP: connected to host "&lt;ip_adress&gt;", 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:&lt;clientCompany@clientDomain&gt;
  250 2.1.0 Sender OK
  RCPT TO:&lt;recipient@clientDomain&gt;
  250 2.1.5 Recipient OK
  DEBUG SMTP: Verified Addresses
  DEBUG SMTP:   recipient@clientDomain
  DATA
  354 Start mail input; end with &lt;CRLF&gt;.&lt;CRLF&gt;
  Message-ID: &lt;181398600.1528806707522.JavaMail.clientCompany@clientDomain&gt;
  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--
  </code></pre>
  
  <h1>2 - Solutions ?</h1>
  
  <p>When I try using the .class with javax.mail 1.5.2 and the SMTP server configuration of my company, it works. I cannot reproduce their error. So our guess is that it may come from their mail server.</p>
  
  <p>I read multiple topics about this problem but could not find any solution yet. May be changing the port from 25 to 587, which is the recommended port, but I really don't see why it would change anything (plus it works with 25 or 587 on my computer). </p>