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
Size: 41
Language: Go
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Stripped down package for sending emails through the Mandrill API. Inspired by @mostafah's implementation.
go get -u github.com/keighl/mandrill
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)
http://godoc.org/github.com/keighl/mandrill
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)
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)
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}
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")