-
-
Save LooseTerrifyingSpaceMonkey/66ec702221eb9e63ee592caa296704f8 to your computer and use it in GitHub Desktop.
Example of sending email from Node.js with SendGrid
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 sendgrid = require('@sendgrid/mail') | |
const SENDGRID_API_KEY = '' | |
sendgrid.setApiKey(SENDGRID_API_KEY) | |
const email = { | |
from: 'yourgmail@yourgmail.com', | |
to: 'myfriend@yahoo.com', | |
subject: 'Sending A Simple Email using Node.js', | |
text: 'Now is the time for all good men to send Email via Node.js!', | |
html: '<h1>SendGrid Test</h1><p>Now is the time for all good men to send Email via Node.js!</p>' | |
} | |
sendgrid.send(email) | |
.then((response) => { | |
console.log('SendGrid Email sent: ' + response) | |
}) | |
.catch((error) => { | |
console.error(error) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment