Grails 2.4.2和邮件插件1.0.6错误

时间:2014-07-19 23:24:36

标签: grails

其他人遇到邮件插件1.0.6和Grails 2.4.2的问题吗?

这很好用:

mailService.sendMail {
    to "test@test.com"
    bcc "test@test.com"
    from "test@test.com"
    subject "test"
    body "test mail"
}

但是在使用视图模板时,例如:

mailService.sendMail {
    to "test@test.com"
    bcc "test@test.com"
    from "test@test.com"
    subject "test"
    html  view:"/mail/test", model:[test:"test"]
}

我在

得到“无法在null对象错误上获取属性'配置'

围绕MailMessageContentRenderer.groovy第65行

65:template.make(model).writeTo(out)

不确定如何解决此问题。任何建议表示赞赏我正试图从控制器发送。

谢谢, 杰夫

1 个答案:

答案 0 :(得分:1)

您需要使用html方法渲染该模板/视图:

sendMail {
  to "john@g2one.com"
  subject "Hello John"
  html g.render(template:"myMailTemplate")
}

你也可以使用body这样的方法:

sendMail {
  to "john@g2one.com"
  subject "Hello John"
  body( view:"/emailconfirmation/mail/confirmationRequest", 
      plugin:"email-confirmation", 
      model:[fromAddress:'bill@microsoft.com'])
}
相关问题