gpc / grails-mail

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

Could not locate mail body /email/JobFail. Is it in a plugin? If so you must pass the plugin name in the [plugin] variable #39

Closed shresthaankit7 closed 2 years ago

shresthaankit7 commented 6 years ago

Hello, I've used "org.grails.plugins:mail:2.0.0.RC6" and "org.grails:grails-plugin-gsp" for send emails using grails3. I've called my mail sending service from another controller with the required params and I've kept the required gsp under the grails-app/views/ folder.

The mail sending service is:

class SendEmailService {
    def mailService
    def serviceMethod(params) {
        try{
            mailService.sendMail {
                to emailList
                from myEmail@gmail.com
                subject "MY_EMAIL_SUBJECT"
                body(view:"/email/JobFail",model:[params])
            }
        }catch (Exception e){
            log.info("**** Error : Sending Job Fail Email:\n******* Cause : " + e.getMessage())
        }
    }
}

The gsp page when my params are mapped is under grails-app/view/email/JobFail.gsp.

Everything in the development environment(using IntelliJ) is working fine but in the production environment, I'm getting a weird issue like: Could not locate mail body /email/JobFail. Is it in a plugin? If so you must pass the plugin name in the [plugin] variable

hefberk commented 6 years ago

after long hours on this bug, i finally found a solution : String contentHTML = g.render(template:"registrationHTML", model:[user: user]) String contentTXT = g.render(template:"registrationTXT", model:[user: user]) sendMail { multipart true subject("SUBJECT") from "FROM" to "TO" html contentHTML text contentTXT }

tonyerskine commented 2 years ago

I had this problem and solved it by adding configuration for the grails GSP plugin. see this question and answer