grails mail plugin
Posted By : Manish Kumar Narang | 30-Sep-2017
In Web applications, sending email is an
def sendEmail(){
mailService.sendMail {
to "email","**email**"
from "email"
subject "Hi"
body 'Hi'
}
}
The plugin is easy to configure and provides some very useful features which can be configured in the config.groovy file.
grails {
mail {
host = "smtp.gmail.com"
port = 465
username = "email"
password = "pwd"
props = ["mail.smtp.auth":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
}
}
I will discuss three of these features -
- grails.mail.overrideAddress
- grails.mail.default.from
- grails.mail.default.to
The email sending functionality in grails framework can be disabled by setting the parameter grails.mail.disabled to be true.
grails.mail.disabled = true
Grails provide an alternative to the disabling
The grails.mail.default.from is clear from its name itself. If the override functionality is enabled, the from addresses of the email is replaced by the email address provided in grails.mail.default.from parameter. One should keep in mind that this will happen only if the grails.mail.overrideAddress is provided.
The grails.mail.default.to is similar to grails.mail.default.from parameter. The replacement will happen in the to addresses of the email.
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Manish Kumar Narang
Manish Narang has skills in software development and is enthusiastic about web applications and loves to work in a team.