Giter Site home page Giter Site logo

mandrill's Introduction

Mandrill Grails Plugin

This is a Grails plugin for the mandrill (http://www.mandrill.com) REST API

Supported Methods

It curently handles :

Installation

Upon install, this plugin adds a section to your Config.groovy file

mandrill {
          apiKey = ""
          // insert proxy values if needed
          //proxy {
          //      host = ""
          // The port Value has to be an integer ;)
          //      port = ""
          //}
          }

You need to fill in the apiKey parameter with the REST api KEY that you get with your mandrill account

Usage

Inject MandrillService into your services or controllers :

def mandrillService

Ping

To call the ping method just type :

def ret = mandrillService.ping()

ret should contain "PONG!"

Info

To call the ping method just type :

def ret =  mandrillService.info()

ret should contain a JSON array with the infos associated to your mandrill API Key

Send

To send a text mail :

def recpts = []
recpts.add(new MandrillRecipient(name:"foo", email:"[email protected]"))
recpts.add(new MandrillRecipient(name:"bar", email:"[email protected]"))
def message = new MandrillMessage(
                                  text:"this is a text message",
                                  subject:"this is a subject",
                                  from_email:"[email protected]",
                                  to:recpts)
message.tags.add("test")
def ret = mandrillService.send(message)

send will return a SendResponse Object with success or error information

To send an HTML mail :

def recpts = []
recpts.add(new MandrillRecipient(name:"foo", email:"[email protected]"))
recpts.add(new MandrillRecipient(name:"bar", email:"[email protected]"))
def message = new MandrillMessage(
                                  html:"<html><body>this is an<b>html</b> message</body></html>",
                                  subject:"this is a subject",
                                  from_email:"[email protected]",
                                  to:recpts)
message.tags.add("test")
def ret = mandrillService.send(message)

send will return SendResponse Object with success or error information

SendTemplate

To send a mail using template :

def recpts = []
recpts.add(new MandrillRecipient(name:"foo", email:"[email protected]"))
recpts.add(new MandrillRecipient(name:"bar", email:"[email protected]"))
def contents = []
contents.add([name:"test name", content:"test content"])
def message = new MandrillMessage(
                                  text:"this is a text message",
                                  subject:"this is a subject",
                                  from_email:"[email protected]",
                                  to:recpts)
message.tags.add("test")
def ret = mandrillService.sendTemplate(message, "templateName", contens )

SendResponse

Per the Mandrill API send calls will respond with:

Example Response JSON
[
  {
      "email": "[email protected]",
      "status": "sent",
      "reject_reason": "hard-bounce",
      "_id": "abc123abc123abc123abc123abc123"
  }
]

Example Error Response JSON
[
  {
      "status": "error",
      "code": 12,
      "name": "Unknown_Subaccount",
      "message": "No subaccount exists with the id 'customer-123'"
  }
]

These fields will be accessible via a SendResponse object:

def ret = mandrillService.sendTemplate(message, "templateName", contens )
if (ret.success) {
    // do successful things
} else {
  log.error("Error sending email: status: $ret.status rejectReason: $ret.rejectReason, message: $ret.message")
}

Note: success is derived from status being either 'sent', 'queued', or 'scheduled'

Contributors

Thanks to James Schindler, gaganc and cympak2 for their contributions

mandrill's People

Contributors

cympak2 avatar dpacaud avatar jimbo1167 avatar serty2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

mandrill's Issues

Is this plugin still available?

Hi

Im trying to install this plugin via Grails compile ":mandrill:0.5"

Yet it's stating it can't find.

Let me know if this plugin is still available- It would greatly help me:)

Thanks
Tyler

Adding attachments

What is the proper format for attachments? The content property on MandrillAttachment is String, but it converts it to binary so when it arrives at the destination it is unreadable.

Error trying to send mails

Class
groovy.lang.MissingPropertyException
Message
No such property: status for class: java.util.HashMap$Entry

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.