Skip to content

NelsonWu419/grails-mailgun

 
 

Repository files navigation

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.

About

Grails plugin to use Mailgun Api

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Groovy 99.8%
  • Shell 0.2%