gpc / grails-mail

The Grails Mail Plugin
http://grails.org/plugin/mail
Apache License 2.0
45 stars 85 forks source link

<g:message> and grailsApplication in HTML emails #29

Closed zoran119 closed 2 years ago

zoran119 commented 9 years ago

I have just upgraded mail plugin in my application from 1.0.1 to 1.0.7 and am now getting NullPointerException when the mail plugin tries to render HTML emails from gsp files which use <g:message> or grailsApplication in them.

Should this be working?

This is my sendMail code:

sendMail {
    to "someone@somewhere.world"
    subject "The best email you will ever get"
    body (
        view: '/email/best',
        model: [who: 'Bob']
    )
}

And this is best.gsp:

<%@ page contentType="text/html" %>
<html>
    <head>
    </head>
    <body>
        <p>
        <g:message code='default.person.name' default='Bob' />
        </p>
   </body>
</html>

Filtered stacktrace:

at grails.plugin.mail.MailMessageContentRenderer$_render_closure1.doCall(MailMessageContentRenderer.groovy:66)
at grails.plugin.mail.MailMessageContentRenderer$RenderEnvironment.with(MailMessageContentRenderer.groovy:180)
at grails.plugin.mail.MailMessageContentRenderer.render(MailMessageContentRenderer.groovy:63)
at grails.plugin.mail.MailMessageBuilder.doRender(MailMessageBuilder.groovy:277)
at grails.plugin.mail.MailMessageBuilder.body(MailMessageBuilder.groovy:259)
at grails.plugin.mail.MailService.sendMail(MailService.groovy:53)
at grails.plugin.mail.MailService.sendMail(MailService.groovy:59)
at MailGrailsPlugin$_configureSendMail_closure6.doCall(MailGrailsPlugin.groovy:165)
arturoojeda commented 9 years ago

I've seen the same behavior after migrating to v 1.0.7 of the mail plugin. I though it was related to the async configuration but it's not. I'm also looking for a solution to this.

thagul commented 8 years ago

Did someone found a solution or a workaround for this issue? I've noticed that the grailsApplication is available till version 1.0.4 and missing starting from version 1.0.5. Unfortunately, version 1.0.4 of mail plugin is not compatible with grails 2.4.x or 2.5.x and I'm stuck in updating my application.