grails / grails-mail

The Grails Mail Plugin
https://grails.github.io/grails-mail/
Apache License 2.0
15 stars 25 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 #30

Closed shresthaankit7 closed 5 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:

@Transactional
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

Guito commented 6 years ago

Hello @shresthaankit7

Did you solve the problem?

jjballano commented 5 years ago

In case of someone came here with that issue, I had the same problem in a small project which only sends emails and it was because I forgot to apply the gsp plugin:

apply plugin:"org.grails.grails-gsp"

sbglasius commented 5 years ago

Question solved