Last active
January 22, 2019 04:45
-
-
Save diegofcornejo/fa733aac2cdcf039fcc10c5db5b81bae to your computer and use it in GitHub Desktop.
Send email with AWS SES in Lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const AWS = require('aws-sdk'); | |
const SES = new AWS.SES({ apiVersion: '2010-12-01' }); | |
module.exports = { | |
send: function() { | |
var params = { | |
Destination: { | |
ToAddresses: [ | |
"[email protected]" | |
] | |
}, | |
Message: { | |
Body: { | |
Html: { | |
Charset: "UTF-8", | |
Data: "Here your Message in <b>HTML</b>" | |
}, | |
Text: { | |
Charset: "UTF-8", | |
Data: "Here your Message in plain text" | |
} | |
}, | |
Subject: { | |
Charset: "UTF-8", | |
Data: "Here you Subject" | |
} | |
}, | |
Source: "[email protected]", | |
}; | |
SES.sendEmail(params, function(err, data) { | |
if (err) console.log(err, err.stack); // an error occurred | |
else console.log(data); // successful response | |
}); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const AWS = require('aws-sdk'); | |
const EMAIL = require('./aws_ses_lambda.js'); | |
exports.handler = (event, context, callback) => { | |
//HERE YOUR CODE | |
EMAIL.send(); | |
callback(null, ':)'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment