Skip to content

Instantly share code, notes, and snippets.

@gene1wood
Created June 28, 2025 01:09
Show Gist options
  • Save gene1wood/32e5c9ce5711505d2b188bb22c808649 to your computer and use it in GitHub Desktop.
Save gene1wood/32e5c9ce5711505d2b188bb22c808649 to your computer and use it in GitHub Desktop.
Twilio function code that BAM Bay Area Mashers use to forward SMS to email
var nodemailer = require("nodemailer");
exports.handler = function(context, event, callback) {
var smtpTransport = nodemailer.createTransport({
host: "mail.smtp2go.com",
port: 2525, // 8025, 587 and 25 can also be used.
auth: {
user: context.SMTP_USERNAME,
pass: context.SMTP_PASSWORD,
},
});
smtpTransport.sendMail({
from: context.FROM_EMAIL_ADDRESS,
to: context.TO_EMAIL_ADDRESS,
subject: `New SMS message from: ${event.From}`,
text: event.Body,
},
function (error, response) {
if(error){
callback(error);
} else {
callback(null, response.message);
}
}
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment