1) Add to build config: compile ":mail:1.0.7"
2) Add email account configuration settings in Config.groovy:
grails.mail.default.from="YOURNAME@gmail.com"
grails {
mail {
host = "smtp.gmail.com"
port = 465
username = "your username" //ex "bob@gmail.com"
password = "aplication_specific_password_from_gmail"
props = ["mail.smtp.auth":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
}
}
Now your email account is set up.
3) Now in your controllers you can use such a closure:
sendMail {
to "email adress"
subject "subject"
body "This is the email body"
}
def sendMail(String email, String confirmationCode){
sendMail {
to email
subject "Queit - confirm your email"
Map model = [confirmationCode:confirmationCode]
html g.render(template:"emailConfirmationTemplate", model:model)
}
}
For additional info check the official documentation: http://grails.org/plugin/mail
No comments:
Post a Comment