Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GrailsMailException: message has no content, use text(), html() or body() methods to set content #45

Closed
wiggitamoo opened this issue Jun 5, 2020 · 1 comment

Comments

@wiggitamoo
Copy link

When running Grails in development my application is sending mail correctly. When I run grails war and deploy to Tomcat, then I get the following error:

GrailsMailException: message has no content, use text(), html() or body() methods to set content

This is how I'm using the sendMail command.

String body = groovyPageRenderer.render(template: "/dfdirHeartbeatAlert/restoreHeartbeatEmail", model: [user: user, message: heartbeatMessage])
        
println(body)

mailService.sendMail {
            multipart true
            bcc bccList.toArray()
            from "<email_address>"
            subject "Subject"
            html body        
}

When I print out body in development it looks correct. However printing body in production deployed on Tomcat comes back as an empty string.

Is this the intended syntax for sending html mail?

@davydotcom
Copy link

Using the groovyPageRenderer like this can be a bit tricky. The mail plugin provides a way to specify the template and the model directly

mailService.sendMail {
            multipart true
            bcc bccList.toArray()
            from "<email_address>"
            subject "Subject"
            html view: "/emails/hello", model: [param1: "value1", param2: "value2"]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants