-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathses-client.js
More file actions
49 lines (43 loc) · 1.23 KB
/
Copy pathses-client.js
File metadata and controls
49 lines (43 loc) · 1.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
const AWS = require('aws-sdk');
const config = require('./config');
AWS.config.update({
accessKeyId: config.aws.key,
secretAccessKey: config.aws.secret,
region: config.aws.ses.region
})
const ses = new AWS.SES({apiVersion: '2010-12-01'});
const sendEmail = (to, subject, message, from) => {
const params = {
Destination: {
ToAddresses: [to]
},
Message: {
Body: {
Html: {
Charset: 'UTF-8',
Data: message
},
/* replace Html attribute with the following if you want to send plain text emails.
Text: {
Charset: "UTF-8",
Data: message
}
*/
},
Subject: {
Charset: 'UTF-8',
Data: subject
}
},
ReturnPath: from ? from : config.aws.ses.from.default,
Source: from ? from : config.aws.ses.from.default,
};
ses.sendEmail(params, (err, data) => {
if (err) {
return console.log(err, err.stack);
} else {
console.log("Email sent.", data);
}
});
};
module.exports = {sendEmail};