Clever/mandrill

Name: mandrill

Owner: Clever

Description: Simple package for sending emails through the Mandrill API.

Created: 2018-02-01 00:07:56.0

Updated: 2018-02-01 00:07:58.0

Pushed: 2018-02-01 00:16:53.0

Homepage:

Size: 41

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Mandrill Emails via Golang

Build Status Coverage Status

Stripped down package for sending emails through the Mandrill API. Inspired by @mostafah's implementation.

Installation
go get -u github.com/keighl/mandrill
Upgrading to 1.0

MessagesSend() and MessagesSendTemplate() now only returns 1 error interface (as opposed to a non-sensical 2).

ew!
 err := client.MessagesSend(m)

ld!
 apiError, err := client.MessagesSend(m)
Documentation

http://godoc.org/github.com/keighl/mandrill

Regular Message

https://mandrillapp.com/api/docs/messages.JSON.html#method=send

rt (
m "github.com/keighl/mandrill"


nt := m.ClientWithKey("XXXXXXXXX")

age := &m.Message{}
age.AddRecipient("bob@example.com", "Bob Johnson", "to")
age.FromEmail = "kyle@example.com"
age.FromName = "Kyle Truscott"
age.Subject = "You won the prize!"
age.HTML = "<h1>You won!!</h1>"
age.Text = "You won!!"

onses, err := client.MessagesSend(message)
Send Template

https://mandrillapp.com/api/docs/messages.JSON.html#method=send-template

http://help.mandrill.com/entries/21694286-How-do-I-add-dynamic-content-using-editable-regions-in-my-template-

lateContent := map[string]string{"header": "Bob! You won the prize!"}
onses, err := client.MessagesSendTemplate(message, "you-won", templateContent)
Including Merge Tags

http://help.mandrill.com/entries/21678522-How-do-I-use-merge-tags-to-add-dynamic-content-

lobal vars
age.GlobalMergeVars = m.MapToVars(map[string]interface{}{"name": "Bob"})

ecipient vars
ars := m.MapToRecipientVars("bob@example.com", map[string]interface{}{"name": "Bob"})
Vars := m.MapToRecipientVars("jill@example.com", map[string]interface{}{"name": "Jill"})
age.MergeVars = []*m.RcptMergeVars{bobVars, jillVars}
Integration Testing Keys

You can pass special API keys to the client to mock success/err responses from MessagesSend or MessagesSendTemplate.

ending messages will be successful, but without a real API request
 ClientWithKey("SANDBOX_SUCCESS")

ending messages will error, but without a real API request
 ClientWithKey("SANDBOX_ERROR")

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.