Question

I installed the mail plugin:

grails install-plugin mail

I added my config according to the plugin:

grails {
    mail {
      host = "smtp.gmail.com"
      port = 465
      username = "youraccount@gmail.com"
      password = "yourpassword"
      props = ["mail.smtp.auth":"true",
               "mail.smtp.socketFactory.port":"465",
               "mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
               "mail.smtp.socketFactory.fallback":"false"]
    }
}

I added a sendMail to my Bootstrap.groovy

try{
 sendMail {
  from "youraccount@gmail.com"
  to "youraccount@gmail.com"
  subject "Hello"
  body "Mail"
 }
}catch (Exception e){
 println e
}

And it gives me nothing! I have tried juggling with the location in the Config.groovy and more things - nothing! It doesn't even give me an exception.

Any ideas?

Was it helpful?

Solution

You need to inject the mail service. In your Bootstrap.groovy:

class BootStrap 
{
    def mailService

    def init = { servletContext ->
        mailService.sendMail {
        }
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top