-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendTransactionalEmails.js
47 lines (42 loc) · 1.18 KB
/
sendTransactionalEmails.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
/* Initialization */
const ElasticEmail = require('@elasticemail/elasticemail-client');
const client = ElasticEmail.ApiClient.instance;
/* Generate and use your API key */
const apikey = client.authentications['apikey'];
apikey.apiKey = "YOUR_API_KEY";
/**
* Send transactional emails
* Example api call that sends transactional email.
* Limit of 50 maximum recipients.
*/
const emailsApi = new ElasticEmail.EmailsApi();
const emailData = {
Recipients: {
To: ["johnsmith@domain.com"]
},
Content: {
Body: [
{
ContentType: "HTML",
Charset: "utf-8",
Content: "<strong>Mail content.<strong>"
},
{
ContentType: "PlainText",
Charset: "utf-8",
Content: "Mail content."
}
],
From: "myemail@domain.com",
Subject: "Example transactional email"
}
};
const callback = (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully.');
console.log('Email sent.');
}
};
emailsApi.emailsTransactionalPost(emailData, callback);