SendGrid.sendEmail()

Send an email

Usage

Hover over inputs/exits for more info.

var SendGrid = require('machinepack-sendgrid');


// Send an email

SendGrid.sendEmail({

apiUser: 'someuser',

apiKey: 'whateverkey',

toEmail: 'jane@example.com',

subject: 'Welcome, Jane!',

textMessage: 'Jane,\nThanks for joining our community. If you have any questions, please don\'t hesitate to send them our way. Feel free to reply to this email directly.\n\nSincerely,\nThe Management',

fromEmail: 'harold@example.enterprise',

toName: 'Jane Doe',

htmlMessage: 'Jane,\nThanks for joining our community. If you have any questions, please don\'t hesitate to send them our way. Feel free to reply to this email directly.\n\nSincerely,\nThe Management',

fromName: 'Harold Greaseworthy',

replyTo: 'support@example.com',

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// OK.

success: function (sendMailResult) {

 

},

});

Inputs

apiUser required

The API user of the Sendgrid account to use.

'someuser'
apiKey required

The API key of the Sendgrid account to use.

'whateverkey'
toEmail required

Must be a valid email address. This can also be passed in as an array, to send to multiple locations. Example: to[]=a@mail.com[]=b@mail.com. Note that recipients passed in this parameter will be visible as part of the message.

'jane@example.com'
subject required

Subject line for the email.

'Welcome, Jane!'
textMessage required

The plain text content of the body body of the email. It must include at least one of the textMessage or htmlMessage parameters.

'Jane,\nThanks for joining our community.  If you have any questions, please don\'t hesitate to send them our way.  Feel free to reply to this email directly.\n\nSincerely,\nThe Management'
fromEmail required

Must be a valid email address from your domain This is where the email will appear to originate from for your recipient

'harold@example.enterprise'
toName

Must be a string. If to parameter is an array, toname must be an array with the exact number of array elements as the to field

'Jane Doe'
htmlMessage

The plain text content of the body body of the email. It must include at least one of the textMessage or htmlMessage parameters.

'Jane,\nThanks for joining our community.  If you have any questions, please don\'t hesitate to send them our way.  Feel free to reply to this email directly.\n\nSincerely,\nThe Management'
fromName

Must a valid string. It is the name appended to the from email field. IE - Your name or company name

'Harold Greaseworthy'
replyTo

Must a valid email address. This is the email that will be used when replying to your email

'support@example.com'

Exits

error

An unexpected error occurred.

success

OK.

'{"message":"success"}'