Grails mail plugin not working

I am trying to send emails from a Grails application, but without any success.

I used gmail and another smtp server (without ssl!), But the same error occurs:

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?

I use in Config.groovy (example for gmail):

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"]

EDIT: , , Javid Jamae, (3- , , ).

, - , ! , Nimble ( Mail ). :
Grails: 1.3.4
Groovy : 1.7.4
JVM: 1.6.0_21
jquery - 1.4.2.5
- 0,9
- 1.0.1
- 0.4-SNAPSHOT

: : , Nimble, NimbleConfig.groovy → mail {... ( "from =..." )}.
, .

+3
5

SSL, Config.groovy( ):

grails {
   mail {
     host = "smtp.gmail.com"
     port = 465
     username = "xxx@gmail.com"
     password = "xxx"
     props = ["mail.smtp.auth":"true",                     
              "mail.smtp.socketFactory.port":"465",
              "mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
              "mail.smtp.socketFactory.fallback":"false"]
   }
}

:

app.grails.version=1.2.1
plugins.mail=0.9

.

+4

SSL:

grails.mail.ssl = "on"

javax.net.ssl.SSLException: SSL, ?.

SSL ( ):

host = "smtp.gmail.com"
port = 465
username = "username@gmail.com"
password = "password"
javaMailProperties = ['mail.smtp.auth': 'true',
        'mail.smtp.socketFactory.port': '465',
        'mail.smtp.socketFactory.class': 'javax.net.ssl.SSLSocketFactory',
        'mail.smtp.socketFactory.fallback': 'false']

, SSL - 587.

mail.smtp.starttls.required: 'true'

, , . starttls.required = true , .

P.S. , SSL TLS - .

+2

"mail.smtp.starttls.enable": "true"

grails.mail.port = 465
+1

, . Nimble ( Mail ) Nimble grails-app/conf/NimbleConfig.groovy.

NimbleConfig.groovy, , , Config.groovy (, NimbleConfig Config).

:

  • Nimble, grails-app/conf/NimbleConfig.groovy; grails-app/conf/Config.groovy

  • Nimble, Mail ( Javid Jamae)

, , OP , , , .

Update:

, NimbleConfig.groovy, :

nimble {
    ...
    messaging {
        ...
        mail {
            host = 'smtp.gmail.com'
            port = 465
            username = '...@gmail.com'
            password = '...'
            props = [
                'mail.smtp.auth': 'true',
                'mail.smtp.socketFactory.port': '465',
                'mail.smtp.socketFactory.class': 'javax.net.ssl.SSLSocketFactory',
                'mail.smtp.socketFactory.fallback': 'false'
            ]
        }
    }
}
0

You can check your configuration settings at runtime by checking mailService.mailSender properties. Something like this: mailService.mailSender.properties.each {Println} It will give the host, port, username, password and a few other values. If you are sure that everything is correct, I would suspect a problem with the firewall.

0
source

Source: https://habr.com/ru/post/1763704/


All Articles