Skip to content

Instantly share code, notes, and snippets.

@realadeel
Created February 11, 2014 17:09
Show Gist options
  • Save realadeel/8939314 to your computer and use it in GitHub Desktop.
Save realadeel/8939314 to your computer and use it in GitHub Desktop.
Example Mandrill message send call - to demonstrate code for preserve recipients.
response = MANDRILL.messages_send(
message: {
html: email.body,
subject: email.subject,
from_email: email.from_email,
from_name: email.from_name,
to: email.recipients.map{|recipient| {email: recipient}},
preserve_recipients: false,
auto_text: true,
inline_css: true,
track_opens: true,
track_clicks: true
},
async: true,
)
@realadeel
Copy link
Author

Example request body:
key=[KEYHIDDEN]&
options[track_opens]=true&
options[track_clicks]=true&
message[html]=hello test.&
message[subject]=test To&
message[from_email]=[EMAIL1HIDDEN]&
message[from_name]=[NAME1HIDDEN]&
message[to][0][email]=[EMAIL2HIDDEN]&
message[to][0][type]=to&
message[to][1][email]=[EMAIL3HIDDEN]&
message[to][1][type]=to&
message[preserve_recipients]=false&
message[auto_text]=true&
message[inline_css]=true&
message[track_opens]=true&
message[track_clicks]=true&
async=true

@realadeel
Copy link
Author

API log:

Full Request
{
"key": "REDACTED",
"options": {
"track_opens": "true",
"track_clicks": "true"
},
"message": {
"html": "test 2",
"subject": "test 2",
"from_email": "REDACTED",
"from_name": "REDACTED",
"to": [
{
"email": "REDACTED"
},
{
"email": "REDACTED"
}
],
"preserve_recipients": "false",
"auto_text": "true",
"inline_css": "true",
"track_opens": "true",
"track_clicks": "true"
},
"async": "true"
}

Full Response
[
{
"email": "REDACTED",
"status": "queued",
"_id": "1b05218290244bb19dc5ed7f8274dd04"
},
{
"email": "REDACTED",
"status": "queued",
"_id": "fe46f28df30b43c194908a234223e369"
}
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment