Reputation: 58712
I am trying to send mail through grails mail plugin. I configured according to the documentation, and also followed few blog posts (http://blog.lourish.com/2010/04/02/sending-asynchronous-html-email-in-grails-with-activemq-jms-and-gmail/). That post mention that the closure way of declaring the configuration overrides others, but not true. Anyway I tried both approach, but seems like the port is still use the smtp default one. I get the below exception.
exception: org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25; nested exception is: java.net.ConnectException: Connection refused: connect
Now, I wrote a small program directly using the java mail library, and I could send the mail with that. The configuration is shown below. tried additional config "mail.smtp.port":"465"", but no change.. used the parameters mentioned in the above blog post, result same
grails {
mail {
host = "smtp.gmail.com"
port = "465"
username = "[email protected]"
password = "mypwd"
props = ["mail.smtp.auth":"true",
// "mail.smtp.port":"465",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
}
}
thanks in advance..
Update: It is not port or firewall config, as when I made a grails application from scratch, and tried with the same config, everything works. Also, asked in grails forum http://grails.1312388.n4.nabble.com/grails-mail-mailSender-does-not-have-config-values-td2237704.html#a2237704 . Hope get a lead to try.
Upvotes: 0
Views: 4811
Reputation: 160
I got it working with the help of this setting
grails {
mail {
host = "smtp.gmail.com"
port = 587
username = "[email protected]"
password = "mypassword"
props = ["mail.debug": "true",
"mail.smtp.protocol": "smtps",
"mail.smtp.auth": "true",
"mail.smtp.starttls.enable": "true",
"mail.smtp.host": "smtp.gmail.com",
"mail.smtp.user": "[email protected]",
"mail.smtp.password": "mypassword"]
}
}
Upvotes: 1
Reputation: 1
Maybe you should try to assign port property an integer value: port = 465 It works fine for me! Good luck!
Upvotes: 0
Reputation: 58712
I think I solved the issue.. I had previously installed Nimble plugin, which also has a mail configuration injected into my application(NimbleConfig.groovy). It worked after I set the mail parameters as in my conf.groovy. I did not see that mailSender is initialized with the nimble config values, and only initialized once from my conf.groovy.. So, I am not sure about the reason, but it worked.
Upvotes: 0