Easily send emails with sendgrid and node.js
npm install sendgrid-web
var Sendgrid = require"sendgrid-web";var sendgrid =user: "firstname.lastname@example.org"key: "oh, like you need to know.";sendgridsendto: 'email@example.com'from: 'firstname.lastname@example.org'subject: 'Hello world!'html: '<h1>Hello world!</h1>'if errconsole.logerr;elseconsole.log"Success.";;
This constructor creates a new sendgrid object. The "credentials" object should contain:
user: Your sendgrid username
key: Your sendgrid API key/password
Sends an email. Options are the same as those of the sendgrid json web api. Common ones include:
- to: The recipient of the email.
- from: The email address to reply back to.
- subject: The subject of the email.
- html: The body of the email, if it's intended to be treated like html.
- text: The body of the email, if it's intended to be treated like plaintext.
In order to run the tests, sendgrid needs a user, api key, and email addresses to send to and from. Before running these tests, open
./test/config-template.json, edit it to contain your credentials and information, and save it as
Then, you may run the tests with nodeunit:
Author: Joshua Holbrook