title: Grails Mail plugin not working
body: <p>I am trying to send mails from a Grails application, but without any success.</p>
  
  <p>I've used gmail and other smtp server (without ssl!) but the same error occurs:</p>
  
  <pre>
  org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Exception reading response;
    nested exception is:
      javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?. Failed messages: javax.mail.MessagingException: Exception reading response;
    nested exception is:
      javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?; message exceptions (1) are:
  Failed message 1: javax.mail.MessagingException: Exception reading response;
    nested exception is:
      javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
  </pre>
  
  <p>I am using in Config.groovy (example for gmail):</p>
  
  <pre>
  grails.mail.host = "smtp.gmail.com"
  grails.mail.from = "xxx@gmail.com"
  grails.mail.port = "465"
  grails.mail.ssl = "on"
  grails.mail.username = "xxx@gmail.com"
  grails.mail.password = "xxx"
  grails.mail.props = ["mail.smtp.auth": "true",
          "mail.smtp.socketFactory.port": "465",
          "mail.smtp.socketFactory.class": "javax.net.ssl.SSLSocketFactory",
          "mail.smtp.socketFactory.fallback": "false",
          "mail.smtp.starttls.enable": "true",
          "mail.debug": "true"]
  </pre>
  
  <p>EDIT: I made a simple app with just the mail plugin and a controller and the config posted by Javid Jamae works (3rd answer, also I think the other should work). </p>
  
  <p>BUT even if I just copy-paste the same config and the same sending mail code, on my primary project it still gives me the same exception! I think this can be caused by Nimble plugin (Mail plugin was installed by it).
  My configuration is:<br>
  Grails version: 1.3.4<br>
  Groovy version: 1.7.4<br>
  JVM version: 1.6.0_21<br>
  jquery - 1.4.2.5<br>
  mail - 0.9<br>
  shiro - 1.0.1<br>
  nimble - 0.4-SNAPSHOT </p>
  
  <p><strong>FINAL EDIT :</strong>
  I resolved the issue: it seems that I have to use the same settings in the Nimble plugin also, in NimbleConfig.groovy -> mail { ...  (must have "from = ...") } .<br>
  Stupid issue, but waisted a lot of time on it.</p>