I am using below code in order to use mail plugin in grails
try {
CH.config.grails.mail.default.from = "${parent_personal_data.email}"
mailSender.username = "${parent_personal_data.email}"
mailSender.password = "${parent_data.password}"
mailService.sendMail {
to "${employee_personal_data.email}"
subject "new task"
body "you have been added to project and you are given a task"
}
}
catch (Exception e) {
// catch block code
}
// Set the original settings back
finally {
CH.config.grails.mail.default.from = defaultFrom
mailSender.username = oldUsername
mailSender.password = oldPassword
}
how ever it keep on showing me the error NO such property: CH no such property :mailSender
I have no idea what CH is in your code or what version of grails you're using, but the appropriate way to get configuration elements is either via
grailsApplication
orHolders
.In a controller or service, you can inject the grailsApplication.
Or you can use the grails.util.Holders class.
Read some docs.