2 Configuration - Reference Documentation
Authors: Grails Plugin Collective
Version: 1.0.8-SNAPSHOT
2 Configuration
2.1 SMTP Server Configuration
By default the plugin assumes an unsecured mail server configured on port 25, getting the SMTP host name from the environment variable SMTP_HOST. However you can change this via the grails-app/conf/Config.groovy file. For example here is how you would configure the default sender to send with a Gmail account:grails { mail { host = "smtp.gmail.com" port = 465 username = "youracount@gmail.com" password = "yourpassword" props = ["mail.smtp.auth":"true", "mail.smtp.socketFactory.port":"465", "mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory", "mail.smtp.socketFactory.fallback":"false"] } }
grails { mail { host = "smtp.live.com" port = 587 username = "youracount@live.com" password = "yourpassword" props = ["mail.smtp.starttls.enable":"true", "mail.smtp.port":"587"] } }
grails.mail.jndiName = "myMailSession"
2.2 Defaults Configuration
You can set various default settings via the application config that will be used in the absence of explicit values when sending mail.You can also set the default "from" address to use for messages in Config using:grails.mail.default.from = "server@yourhost.com"
grails.mail.default.to = "user@yourhost.com"
2.3 Other Configuration
Disabling Mail Sending
You can completely disable the sending of mail by setting:grails.mail.disabled = true
mailService.sendMail()
as a no-op which means that the mail plugin will not attempt to render the email message or assemble any attachments. This can hide issues such as incorrect view names, invalid configuration or non existent during development.Consider using the greenmail plugin which allows you to start an in memory test SMTP server for local development. This allows you to test more of your code.Overriding Addresses
An alternative to disabling email or using something like the greenmail plugin is to use theoverrideAddress
config setting for your development and/or test environment to force all mail to be delivered to a specific address, regardless of what the addresses were at send time:grails.mail.overrideAddress = "test@address.com"