-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend-email.js
52 lines (46 loc) · 1.51 KB
/
send-email.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
const AWS = require('aws-sdk');
const params = {
Destination: {
CcAddresses: ['[email protected]'], // this addrress would receive a copy
ToAddresses: ['[email protected]'],
},
Message: {
Body: {
Html: {
Charset: 'UTF-8',
Data: "<h1>Hey Ikhlas, Watsup</h1>"
},
Text: {
Charset: 'UTF-8',
Data: "Hey Ikhlas, Watsup"
},
},
Subject: {
Charset: 'UTF-8',
Data: 'Test from NodeAws SES'
}
},
Source: '[email protected]',
ReplyToAddresses: ['[email protected]']
}
const sendEmail = () => {
// // 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);
// });
}
const verifyEmail = (email) => {
// Create promise and SES service object
var verifyEmailPromise = new AWS.SES({apiVersion: '2010-12-01'}).verifyEmailIdentity({EmailAddress: email}).promise();
// Handle promise's fulfilled/rejected states
verifyEmailPromise
.then(data => console.log("Email verification initiated", data))
.catch((err) => console.error(err, err.stack));
}
module.exports = { sendEmail, verifyEmail };