Last active
September 28, 2020 19:53
-
-
Save sendgrid-gists/069d788aefb7853706f424cbdfd7ee3c to your computer and use it in GitHub Desktop.
v3 "Hello World" for email, using SendGrid with Node.js.
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
// using Twilio SendGrid's v3 Node.js Library | |
// https://github.com/sendgrid/sendgrid-nodejs | |
javascript | |
const sgMail = require('@sendgrid/mail') | |
sgMail.setApiKey(process.env.SENDGRID_API_KEY) | |
const msg = { | |
to: 'test@example.com', // Change to your recipient | |
from: 'test@example.com', // Change to your verified sender | |
subject: 'Sending with SendGrid is Fun', | |
text: 'and easy to do anywhere, even with Node.js', | |
html: '<strong>and easy to do anywhere, even with Node.js</strong>', | |
} | |
sgMail | |
.send(msg) | |
.then(() => { | |
console.log('Email sent') | |
}) | |
.catch((error) => { | |
console.error(error) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment