Skip to content


Repository files navigation


Slack Signup Travis CI


The Grails SendGrid plugin allows you to use the services offered by SendGrid to send email from your application.

The plugin works for Grails 3.x. For Grails 2.x please refer to the 1.x branch


Add the following dependencies in build.gradle

dependencies {
    compile 'desirableobjects.grails.plugins:grails-sendgrid:2.0.1'


Configuration takes place in your application's yaml file.

The basic configuration you will need to use the plugin is:

        username: 'your-username'
        password: 'your-password'

Where your-username and your-password should be replaced with your sendgrid login details.

If you need to override the sengrid API endpoint (such as for development/integration environments, to replace it with a fake 'fixture'), you can do that in the same place:

            url: 'http://localhost:8080/your-application/fixture/'
        username: 'your-username'
        password: 'your-password'

Note that your @fixture@ controller must have the 'mail.send.json' action configured, and sending and receiving @application/json@ content, as this is what the plugin expects to call.

Sending Email

In a pinch, you can send email using the SendGridService in one of two ways:

  • Using the sendMail method of the SendGridService directly:
sendGridServicesendMail {
     from ''
     to ''
     to ''
     bcc ''
     subject 'This is the subject line'
     body 'This is our message body'
  • Using the email builder

This is useful when you might want a more programmatic approach to sending email.

SendGridEmail email = new SendGridEmailBuilder()
                        .subject('This is the subject line')
                        .withText('This is our message body')

When you've built your email, pass it to the SendGridService's send method:


The email builder is written as a natural-language type DSL, so you might find that there is more than one way to build your email, but under the covers, they are exactly the same.

For further details, see the sendgrid api []