-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathses.js
37 lines (34 loc) · 1012 Bytes
/
ses.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
const aws = require("aws-sdk");
let secrets;
if (process.env.NODE_ENV == "production") {
secrets = process.env; // in prod the secrets are environment variables
} else {
secrets = require("./secrets"); // in dev they are in secrets.json which is listed in .gitignore
}
const ses = new aws.SES({
accessKeyId: secrets.AWS_KEY,
secretAccessKey: secrets.AWS_SECRET,
region: "eu-west-1"
});
exports.sendEmail = function(recipient, message, subject) {
return ses
.sendEmail({
Source: "thePond <thePond@fantasymail.de>",
Destination: {
ToAddresses: [recipient]
},
Message: {
Body: {
Text: {
Data: message
}
},
Subject: {
Data: subject
}
}
})
.promise()
.then(() => console.log("it worked!"))
.catch(err => console.log(err));
};