Created
June 28, 2025 01:09
-
-
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
This file contains hidden or 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
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