forked from timmyg/meteor-mandrill
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmandrill.js
36 lines (34 loc) · 1.16 KB
/
mandrill.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Meteor.Mandrill = {
options: {},
config: function (options) {
this.options.username = options["username"];
this.options.key = options["key"];
this.options.host = "smtp.mandrillapp.com";
this.options.port = "587";
// setn the environment SMTP server
process.env.MAIL_URL = "smtp://" + this.options.username + ":" + this.options.key + "@" + this.options.host + ":" + this.options.port + "/";
},
send: function (options) {
Email.send(options);
},
sendTemplate: function (options) {
var url = "https://mandrillapp.com/api/1.0/messages/send-template.json",
result;
options = {
"data": {
"key": options.key || this.options.key,
"template_name": options.template_name,
"template_content": options.template_content,
"message": options.message,
"headers": [{
"Content-Type": "application/json"
}]
}
};
try {
return HTTP.post(url, options);
} catch (err) {
console.error(err);
}
}
};