© 2010 David Gustafsson

Configure Grails AcegiSecurity Plugin with GMail

I have just got the mail plugin working with Grails and GMail. The plugin can be configured to send an e-mail when for example a user registers. To get this to work with gmail use the following settings:

useMail = true
mailHost = “smtp.gmail.com”
mailFrom = “admin@yourdomain.com”
mailPort = “465″
mailUsername = “username@gmail.com”
mailPassword = “password”
javaMailProperties = ["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"]

A few forums discuss this topic but I could not find a solution in either of them. The standard settings the plugin authors give does not work. This Wordpress post discusses how to add asynchronous mail to the mail-plugin and brings up the setting that have to be made to the underlying mail plugin. He uses almost the settings I use for his purpose in the asynchronous plugin, however I adapted these to the mail plugin. Give it a try!

AcegiSecurity Plugin