-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlambda.js
47 lines (40 loc) · 1.41 KB
/
lambda.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
// Lambda function to send a static email preconfigured with a boilerplate status update
// Configure with environment variables
// sesRegion: SES region ex: us-east-1
// sourceEmail: from email address - must be SES verified
// recipientList: to email adresseses
var aws = require('aws-sdk');
var ses = new aws.SES({
region: process.env.sesRegion
});
exports.handler = function(event, context) {
console.log("Incoming: ", event);
var d = new Date();
var eParams = {
Destination: {
ToAddresses: [process.env.recipientList]
},
Message: {
Body: {
Text: {
Data: "Running late. Be in soon.\n\nYesterday:\nMeetings\nMoving cards\nSorting email\nDealing with server issues\n\nToday:\nDoing what was supposed to be done yesterday\n\nIn my way:\nRunning late\n\nPowered by AWS IoT"
}
},
Subject: {
Data: "Scrupdate for " + d.toLocaleDateString()
}
},
Source: process.env.sourceEmail
};
console.log('===SENDING EMAIL===');
var email = ses.sendEmail(eParams, function(err, data){
if(err) console.log(err);
else {
console.log("===EMAIL SENT===");
console.log(data);
console.log("EMAIL CODE END");
console.log('EMAIL: ', email);
context.succeed(event);
}
});
};