title: Sending email with javax.mail: the newer version of the library brings unexpected errors
body: <p>In the past I have used many times javax.mail to send emails in my programs, without any problems. The version I was using is 1.4.5</p>
  
  <p>Now I have downloaded the latest version of the library (1.6.5 - which is now called jakarta.mail) from here: eclipse-ee4j.github.io/mail, but i have problems using it. This is my code (it does not change when changing libraries):</p>
  
  <pre><code>            Properties properties = new Properties();
              properties.put("mail.transport.protocol", "smtp");
              properties.put("mail.smtp.host", host);
              properties.put("mail.smtp.port", port);
              properties.put("mail.smtp.auth", "true");
              properties.put("mail.smtp.starttls.enable", "false");
  
              Authenticator authenticator = new Authenticator() {
                  @Override
                  protected PasswordAuthentication getPasswordAuthentication() {
                      return new PasswordAuthentication(username, password);
                  }
              };
  
              Session session = Session.getDefaultInstance(properties, authenticator);    
              session.setDebug(true);        
              MimeMessage message = new MimeMessage(session);
              message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
              message.addRecipient(Message.RecipientType.TO, new InternetAddress(cc));
              message.setFrom(new InternetAddress(sender, senderName));
              message.setSubject(oggetto);            
              message.setText(testo);
  
              Transport.send(message);
  </code></pre>
  
  <p>This is what i get when sending the message using the "new library" (I have activated the session debug):</p>
  
  <pre><code>DEBUG: setDebug: Jakarta Mail version 1.6.5
  DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
  DEBUG SMTP: need username and password for authentication
  DEBUG SMTP: protocolConnect returning false, host=10.255.59.13, user=mmiorandi, password=&lt;null&gt;
  DEBUG SMTP: useEhlo true, useAuth true
  DEBUG SMTP: trying to connect to host "10.255.59.13", port 25, isSSL false
  220 vinfosynapp01 ESMTP
  DEBUG SMTP: connected to host "10.255.59.13", port: 25
  EHLO IS01.Infosyn.com
  250-vinfosynapp01
  250-SIZE
  250-AUTH LOGIN
  250 HELP
  DEBUG SMTP: Found extension "SIZE", arg ""
  DEBUG SMTP: Found extension "AUTH", arg "LOGIN"
  DEBUG SMTP: Found extension "HELP", arg ""
  DEBUG SMTP: protocolConnect login, host=10.255.59.13, user=smtp@infosyn4.loc, password=&lt;non-null&gt;
  DEBUG SMTP: Attempt to authenticate using mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM XOAUTH2 
  DEBUG SMTP: Using mechanism LOGIN
  DEBUG SMTP: AUTH LOGIN command trace suppressed
  DEBUG SMTP: AUTH LOGIN failed
  javax.mail.AuthenticationFailedException: 535 Authentication failed. Restarting authentication process.
  
      at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:947)
      at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:858)
      at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:762)
      at javax.mail.Service.connect(Service.java:364)
      at javax.mail.Service.connect(Service.java:222)
      at javax.mail.Service.connect(Service.java:171)
      at javax.mail.Transport.send0(Transport.java:230)
      at javax.mail.Transport.send(Transport.java:100)
  ...
  </code></pre>
  
  <p>And this is waht i get when using the "old" one:</p>
  
  <pre><code>DEBUG: setDebug: JavaMail version 1.4.5
  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 "10.255.59.13", port 25, isSSL false
  220 vinfosynapp01 ESMTP
  DEBUG SMTP: connected to host "10.255.59.13", port: 25
  
  EHLO IS01.Infosyn.com
  250-vinfosynapp01
  250-SIZE
  250-AUTH LOGIN
  250 HELP
  DEBUG SMTP: Found extension "SIZE", arg ""
  DEBUG SMTP: Found extension "AUTH", arg "LOGIN"
  DEBUG SMTP: Found extension "HELP", arg ""
  DEBUG SMTP: Attempt to authenticate
  DEBUG SMTP: check mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM 
  DEBUG SMTP: AUTH LOGIN command trace suppressed
  DEBUG SMTP: AUTH LOGIN succeeded
  ...
  </code></pre>
  
  <p>The first difference that I can see is the "check mechanism": LOGIN PLAIN DIGEST-MD5 NTLM XOAUTH2 vs LOGIN PLAIN DIGEST-MD5 NTLM.
  Could it somehow be the problem?</p>