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 is an experienced Backend Developer with several years of industry experience in the IT field. He possesses a wide range of skills, including expertise in Backend languages like Core Java, J2EE, Hibernate, Spring/Spring Boot, and Python. Manish is also proficient in relational databases such as MySQL, PostgreSQL, and Oracle. He has hands-on experience in API implementations, web services development, testing, and deployments. Manish has contributed to various internal and client projects, including PMO, Catalyst, Communication-Scaffold, Oodles-Dashboard, and Devops Support, delivering significant business value. He is known for his innovative mindset and excellent problem-solving abilities. He keeps himself updated with new technologies by reading about them. He is skilled at collaborating closely with clients to define project scope and requirements, establish project timelines and milestones, and manage expectations. Manish conducts regular project status meetings, ensuring regular updates to clients and stakeholders regarding project progress, risks, and issues. Additionally, he serves as a mentor and coach to junior developers, offering guidance on project management best practices and fostering their skills development.