title: JavaMail with MS Exchange: No authentication mechansims supported by both server and client
body: <p>I've been trying for days now to send mail from Grails application and unsuccessfully. I'm using:</p>
  
  <ul>
  <li>grails 1.3.7</li>
  <li>mail 1.0 plugin</li>
  <li>spring-security-core 1.2.6 plugin</li>
  <li>tomcat 7.0.23</li>
  </ul>
  
  <p>Specifficaly I'm trying to send mail with Exchange from application deployed on Tomcat server trought port 25 with no authentication, no SSL.</p>
  
  <p>I've tried to send message with telnet from the VMWare virtual machine on which the app is deployed and it got trough.</p>
  
  <p>This is my class for sending mails:</p>
  
  <pre><code>public boolean sendMessage(String to, String msgSubject, String msgText) 
  {
      String host = "mail.mydomain.com";
      String username = "myuser@mydomain.com"; // your authsmtp username
      String password = "mypassword" // your authsmtp password
      String from = "myuser@mydomain.com";
  
      Properties props = System.getProperties();
      props.put("mail.smtp.host", host);
      props.put("mail.smtp.user", username);
      props.put("mail.smtp.password", password);
      props.put("mail.smtp.port", "25"); // thish is the port recommended by authsmtp
      props.put("mail.smtp.auth", "false");
  
      Session session = Session.getDefaultInstance(props, null);
      MimeMessage message = new MimeMessage(session);
      message.setFrom(new InternetAddress(from));
  
      InternetAddress to_address = new InternetAddress(to);
      message.addRecipient(Message.RecipientType.TO, to_address);
  
      message.setSubject(msgSubject);
      message.setText(msgText);
      Transport transport = session.getTransport("smtp");
      transport.connect(host, username, password);
      transport.sendMessage(message, message.getAllRecipients());
      transport.close();
      return true;
  }
  </code></pre>
  
  <p>This is error stack trace:</p>
  
  <pre><code>javax.mail.AuthenticationFailedException: No authentication mechansims supported by both server and client
  
  at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:590)
  
  at javax.mail.Service.connect(Service.java:291)
  
  at javax.mail.Service.connect(Service.java:172)
  
  at javax.mail.Service$connect.call(Unknown Source)
  
  at org.helpdesk.MymailService.sendMessage(MymailService.groovy:37)
  
  at org.helpdesk.MymailService$sendMessage.call(Unknown Source)
  
  at org.helpdesk.RequestController$_closure13.doCall(RequestController.groovy:247)
  
  at org.helpdesk.RequestController$_closure13.doCall(RequestController.groovy)
  
  at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  
  at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>I've read few dozen posts considering problems like this but I've still havent manage to solve the problem. Any help is appreciated.</p>
  
  <p>*<em>EDIT:</em>*Is it possible that there are some problems sending mails using javaMail with Exchange server SMTP when there is no authentication?</p>