dpacaud / mandrill

This is a Grails plugin for the mandrill (http://www.mandrillapp.com) REST API
11 stars 13 forks source link

Send img inline #15

Open flopezd opened 8 years ago

flopezd commented 8 years ago

Hello, there is any way to send an inline image(encoding base64) to the template. This is supported by the api (https://mandrillapp.com/api/docs/messages.html), but i cant find the way to do it. Thanks!

bangroot commented 7 years ago

As a work around, I've done the following to add the images property to the metaClass of MandrillMessage and included it in the JSON serialization.

in BootStrap.groovy:

org.grails.mandrill.MandrillMessage.metaClass.images = []
grails.converters.JSON.registerObjectMarshaller(org.grails.mandrill.MandrillMessage) {
    def val = it.properties.findAll {k,v -> k != 'class'}
    val.images = it.images
    return val
}

Then, elsewhere something like:

message.images = [
  [ type: 'image/png',
    name: 'logo',
    content: logo.encodeBase64().toString()
  ]
]