Meteor package for sending email via Mandrill
$ meteor add wylio:mandrill
# in server code
Meteor.startup(function() {
return Meteor.Mandrill.config({
username: "YOUR_MANDRILL_USERNAME",
key: "YOUR_MANDRILL_API_KEY"
});
});
this.sendEmail = function(to, subject, htmlText) {
return Meteor.Mandrill.send({
to: to,
from: fromEmail,
subject: subject,
html: htmlText
});
};
Read more on how to use merge tags in the Mandrill docs.
The sendTemplate
method uses Mandrill's https://mandrillapp.com/api/1.0/messages/send-template.json
call.
Find out what else you can send, including how to send mc:edit regions, by reviewing the Mandrill API documentation.
#server code
Meteor.Mandrill.sendTemplate({
"key": "YOUR_MANDRILL_API_KEY", // optional, if you set it in with Meteor.Mandril.config() already
"template_name": "YOUR_TEMPLATE_SLUG_NAME",
"template_content": [
{}
],
"message": {
"global_merge_vars": [
{
"name": "var1",
"content": "Global Value 1"
}
],
"merge_vars": [
{
"rcpt": "[email protected]",
"vars": [
{
"name": "fname",
"content": "John"
},
{
"name": "lname",
"content": "Smith"
}
]
}
],
"to": [
{"email": [email protected]}
]
}
});