I added to Config.groovy default mail body by adding this line:
grails.mail.default.body = "Test body"
and then I am passing adress, subject and body from form by params in a sendMail method:
sendMail {
to params.adress
subject params.title
body params.body
}
It works fine if params.body is not empty, but when user ignores this field the default body is not added to mail – the mail cant be sent without body.
Class
grails.plugin.mail.GrailsMailException
Message
message has no content, use text(), html() or body() methods to set content
What mistake I did here? Is there some special way I need to handle default content of mail body, subject or other fields?
The mail plugin has special support for
default.toanddefault.frombut notdefault.body(or subject, or anything else). You could handle it yourself:but the plugin won’t do it for you.