Created
May 11, 2020 20:19
-
-
Save AmrAbdalrahman/5865592f8e5ba1184a9e8c65c1685b93 to your computer and use it in GitHub Desktop.
use sendgrid to send email with nodeJS
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
const nodemailer = require('nodemailer'); | |
const sendgridTransport = require('nodemailer-sendgrid-transport'); | |
const transporter = nodemailer.createTransport( | |
sendgridTransport({ | |
auth: { | |
api_key: | |
process.env.SENDGRID_API_KEY | |
} | |
}) | |
); | |
exports.sendEmail(mailOptions) { | |
transporter.sendMail({ | |
to: mailOptions.to, | |
from: mailOptions.from, | |
subject: mailOptions.subject, | |
html: mailOptions.html | |
})} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment