Search code examples
javaemailgrailscontent-typegrails-plugin

How to set the content type with Grails mail plugin?


The Grails mail plugin documentation shows only how to set the content type with GSP templates:

<%@ page contentType="text/html"%>

But I don't use GSP (and will not!) and produce a String with FreeMarker. Is there a way to set the content type without using GSP?


Solution

  • If you use the html statement in the sendMail method the plugin will set the content type for you. The sendMail command can be used without requiring a gsp template.

    mailService.sendMail {
                to "[email protected]"
                from "[email protected]"
                subject "Email without gsp"
                html "some markup"
            }