Show Navigation

grails-mailgun

Grails grails-mailgun plugin

Owner: orkonano | 2.0.3-b | May 23, 2017 | Package | Issues | Source | License: Apache-2.0


dependencies {
    compile 'org.grails.plugins:grails-mailgun:2.0.3-b'
}

            

Build Status Project Status Stories in Ready

grails-mailgun

Grails plugin to use Mailgun Api.

¬°IMPORTANT! You need to create your own mailgun account. The plugin doesn't work without a valid api-key and a valid domain

Config parameters

You need to set into your Config.groovy the following properties:

mailgun{
       apiKey = 'test'
       domain = 'test'

       message{
              defaultFrom = 'test'
              defaultTo = 'test'
              defaultSubject = 'BigHamlet tiene promociones para vos'
              format = 'html'
              defaulTemplate = '/test/mailgunTest'
              defaultReplyTo = 'test'
       }
}

The full list of properties is:

mailgun{
       apiKey = 'test'
       domain = 'test'

       message{
              defaultFrom = 'test'
              defaultTo = 'test'
              defaultSubject = 'BigHamlet tiene promociones para vos'
              format = 'html'
              defaulTemplate = '/test/mailgunTest'
              defaultReplyTo = 'test'
       }

       tracking{
              enabled = 'yes'
              clicks{
                     enabled = 'yes'
              }
              opens{
                     enabled = 'yes'
              }
       }
}

Mailgun Features

The plugin allows to work with some features of mailgun:

  • Lists all mail list created in mailgun: Mailgun endpoint --> GET: https://api.mailgun.net/v3/lists
  • Sends message across Mailgun Api: Mailgun endpoint --> POST: https://api.mailgun.net/v3/$domain/messages

Email Html Render

The plugin define a default email html render. DefaultEmailHtmlRender.groovy It render a view (gsp) passing a model as params


    String render(Map params){
        groovyPageRenderer.render view: params.view, model: params.model
    }
    

Examples

 class TestController {

    def mailgunService

    def index() {
        RestResponse resp = mailgunService.allLists

        render resp.json.items
    }

    def send() {
        RestResponse resp = mailgunService.sendMessage()

        render resp.status
    }
}

Examples

 class TestController {

    def mailgunService

    def index() {
        RestResponse resp = mailgunService.allLists

        render resp.json.items
    }

    def send() {
        RestResponse resp = mailgunService.sendMessage()

        render resp.status
    }
}

MailgunService implements all features.

The method allLists, lists all mail lists created in mailgun.

The method sendMessage, sends a new message across mailgun api.