RohanRasane
RohanRasane

Reputation: 60

How to send an email in grails

My app wants to send an email using the custom mailers. I went through the doc http://grails.org/Mail+from+Grails which I find pretty incomplete. I followed the steps mentioned in the alternative mailer, but I get an exception

NullPointerException occurred when processing request: [GET] url/sendEmail Cannot invoke method sendNewEmail() on null object.

My controller looks like this

XXXMailer paMailer paMailer.sendNewEmail()

Upvotes: 1

Views: 2633

Answers (2)

Dónal
Dónal

Reputation: 187499

The web page you linked to is merely a proposal which may have never been implemented and hasn't been updated in 3 years. The most popular way to to send email from a Grails app is with the mail plugin. The docs are comprehensive, and it's very easy to use.

Upvotes: 5

Igor Artamonov
Igor Artamonov

Reputation: 35961

XXXMailer seems to be a service, or any other automatically wired thing. So, you have to define it as field, and only then used it from an method, like:

class MyController {

    XXXMailer paMailer //now it will be filled with real instance

    def myAction() {
        paMailer.sendNewEmail()
    }
}

Upvotes: 0

Related Questions