Closed AlexKovynev closed 7 years ago
I have the same Problem on Grails 3.1.3! Have you found any workaround yet?
Unfortunately not, the plugin developer does not respond to errors :( graemerocher save us!:)
I find workaround! Set grails.serverURL in config (for development enviroment too - "http://localhost:8080" )
I had this same issue when sending an email from a JMS listener. I was able to workaround it without needing to set the grails.serverURL. I injected the groovyPageRenderer and rendered the email template myself and passed the string value to the html parameter of the sendMail closure. Below is an example of how I was able to accomplish it with some hand waving (I am obviously missing all of the jms annotations and static methods)
import grails.gsp.PageRenderer
class SomeJmsListenerService {
def mailService
PageRenderer groovyPageRenderer
def onMessage(String jsonMessage) {
String emailTemplate = groovyPageRenderer.render([view: "/email/_emailTemplate", model: [userName: "Bob"]])
mailService.sendMail {
to "bob@somemailserver.com"
subject "Hello Bob"
html emailTemplate
}
}
}
There may still be an issue in war deployments. Looks like it is looking for gsp files under: '/WEB-INF/grails-app/views' when the files are located in '/WEB-INF/classes'
Created a PR for this: https://github.com/grails3-plugins/mail/pull/24
PR #24 was merged. Closing this issue
With 3.1.0 it's all ok.