Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const nodemailer = require('nodemailer');
- exports.handler = function(context, event, callback) {
- let transporter = nodemailer.createTransport(
- {
- host: context.SMTP_HOST,
- port: context.SMTP_PORT,
- auth: {
- type: 'login',
- user: context.AWS_ACCESS_KEY_ID,
- pass: context.AWS_SECRET_ACCESS_KEY,
- },
- }
- );
- let email = {
- from: context.FROM_EMAIL_ADDRESS,
- to: context.TO_EMAIL_ADDRESS,
- subject: 'Subject',
- text: event.Body,
- priority: 'high',
- };
- let sendPromise = transporter.sendMail(email);
- sendPromise.then(
- function(data) {
- let twiml = new Twilio.twiml.MessagingResponse();
- callback(null, twiml);
- }
- ).catch(
- function(err) {
- callback(err);
- }
- );
- };
Add Comment
Please, Sign In to add comment