-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendEmailMadrill.js
64 lines (52 loc) · 1.5 KB
/
sendEmailMadrill.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
if (Meteor.isServer) {
var sendToEmailAddress = "[email protected]";
var fromEmailAddress = "[email protected]"
var mandrillUserName = "your mandrill emailaddress";
var mandrillApiKey = "your mandrill API key";
Meteor.startup(function () {
Mandrill.config({
username: mandrillUserName,
key: mandrillApiKey
});
Meteor.setTimeout(function(){
Meteor.call("sendMandrillEmail");
}, 3000);
});
Meteor.methods({
sendMandrillEmail : function (){
console.log("sending email...");
var result = Mandrill.messages.sendTemplate({
template_name: 'email-template',
template_content: [
{
name: 'body',
content: 'content'
}
],
message: {
subject: 'Hello from your Meteor App',
from_email: fromEmailAddress,
to: [
{ email: sendToEmailAddress }
],
merge_language: 'handlebars',
global_merge_vars: [
{
name: 'USERFIRSTNAME',
content: "USER"
},
{
name: 'ITEMS',
content: [
'Item 1',
'Item 2',
'Item 3'
]
}
]
}
});
console.log(result.data[0].status);
}
});
}