-
Notifications
You must be signed in to change notification settings - Fork 0
/
ses_sendemail.js
56 lines (53 loc) · 1.25 KB
/
ses_sendemail.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
// Load the AWS SDK for Node.js
var AWS = require("aws-sdk");
// Set the region
AWS.config.update({ region: "us-east-1" });
// Create sendEmail params
var params = {
Destination: {
/* required */
CcAddresses: [
/* more items */
],
ToAddresses: [
/* more items */
],
},
Message: {
/* required */
Body: {
/* required */
Html: {
Charset: "UTF-8",
Data: "<h1 style='''color:green;font-size:46px;'''>Hi, recieving this from aws ses service</h1>",
},
Text: {
Charset: "UTF-8",
Data: "Hi , you are reciving this email from aws ses service",
},
},
Subject: {
Charset: "UTF-8",
Data: "SES Test mail",
},
},
Source: "[email protected]" /* required */,
ReplyToAddresses: [
/* more items */
],
};
// Create the promise and SES service object
var sendPromise = new AWS.SES({ apiVersion: "2010-12-01" })
.sendEmail(params)
.promise();
// Handle promise's fulfilled/rejected states
sendPromise
.then(function (data) {
console.log(data.MessageId);
})
.catch(function (err) {
console.error(err, err.stack);
});