Skip to content

Instantly share code, notes, and snippets.

@LooseTerrifyingSpaceMonkey
Created June 29, 2022 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LooseTerrifyingSpaceMonkey/66ec702221eb9e63ee592caa296704f8 to your computer and use it in GitHub Desktop.
Save LooseTerrifyingSpaceMonkey/66ec702221eb9e63ee592caa296704f8 to your computer and use it in GitHub Desktop.
Example of sending email from Node.js with SendGrid
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