This repository was archived by the owner on Sep 30, 2025. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathsend.js
More file actions
77 lines (75 loc) · 2.23 KB
/
Copy pathsend.js
File metadata and controls
77 lines (75 loc) · 2.23 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
var mandrill = require("mandrill-api/mandrill");
mandrill_client = new mandrill.Mandrill("API_KEY");
var template_name = "anomaly-alert";
var template_content = [];
var merge_vars = [
{
name: "MAINCONTENT",
content: "<h1>Facebook_fb_spend</h1><h1>last 15 days Avg. = 2633.88</h1>"
},
{
name: "VISUALS",
content:
"<img src='?ui=2&ik=5c0deb2486&view=fimg&th=1646fa8252794773&attid=0.2&disp=emb&realattid=cef73acc1c777565_0.1.1&attbid=ANGjdJ8fo25tRcXez3xejvZ-zp0cE8Lw1EHVpvNu7vwyzMf0R8QkFD6rhbH2UEc2prf9xPcS9_gL6VKVAGTrEVulp8vZjp41-6H04Fhze2p89AH2SU2oAXwTly9CUXQ&sz=s0-l75-ft&ats=1532496034416&rm=1646fa8252794773&zw&atsh=1' alt='Facebook_fb_impressions' class='CToWUd a6T' tabindex='0' width='100%' height='100%'>"
}
];
mandrill_client.templates.render(
{
template_name: template_name,
template_content: template_content,
merge_vars: merge_vars
},
function(result) {
sendMail(result);
},
function(e) {
console.log("A mandrill error occurred: " + e.name + " - " + e.message);
}
);
function sendMail(result) {
var message = {
html: result.html,
text: "Test email template text content",
subject: "Test email template",
from_email: "support@clarisights.com",
from_name: "Clarisights",
to: [
{
email: "yash.arora@adwyze.com",
name: "Yash Arora",
type: "to"
}
],
headers: {
"Reply-To": "support-reply@clarisights.com"
},
important: false,
track_opens: null,
track_clicks: null,
auto_text: null,
auto_html: null,
inline_css: null,
url_strip_qs: null,
preserve_recipients: null,
view_content_link: null,
bcc_address: "yash.arora@adwyze.com",
tracking_domain: null,
signing_domain: null,
return_path_domain: null,
merge: true,
merge_language: "mailchimp",
tags: ["test"]
};
var async = false;
var ip_pool = "Main Pool";
var send_at = "2015-01-01 00:00:00";
mandrill_client.messages.send(
{ message: message, async: async, ip_pool: ip_pool, send_at: send_at },
function(result) {
console.log(result);
},
function(e) {
console.log("A mandrill error occurred: " + e.name + " - " + e.message);
}
);
}