-
Notifications
You must be signed in to change notification settings - Fork 2
/
mailer.js
47 lines (45 loc) · 917 Bytes
/
mailer.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
let aws = require('aws-sdk')
aws.config.update({region:'us-east-2'})
try {
require('dotenv').config()
} catch (e) {}
function send (subject, to, text) {
var params = {
Destination: { /* required */
ToAddresses: [
to
]
},
Message: {
Body: {
Html: {
Charset: 'UTF-8',
Data: text
},
},
Subject: {
Charset: 'UTF-8',
Data: subject
}
},
Source: process.env.EMAIL_ADDRESS,
ReplyToAddresses: [
process.env.EMAIL_ADDRESS
],
ReturnPath: process.env.EMAIL_ADDRESS
}
const ses = new aws.SES({apiVersion: '2010-12-01'})
return new Promise((resolve, reject) => {
ses.sendEmail(params, function (err, data) {
if (err || !data) {
console.log(err)
console.log(data)
reject(err)
}
resolve(data)
})
})
}
module.exports = {
send: send
}