Grails plugin to use Mailgun Api
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
gradle/wrapper
grails-app
src
.gitignore
.travis.yml
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
travis-build.sh
travis-publish.sh

README.md

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:

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.