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: '[email protected]',

subject: 'Welcome, Jane!',

textMessage: 'Jane,\n' + "Thanks 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" + '\n' + 'Sincerely,\n' + 'The Management',

fromEmail: '[email protected]',

toName: 'Jane Doe',

htmlMessage: 'Jane,\n' + "Thanks 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" + '\n' + 'Sincerely,\n' + 'The Management',

fromName: 'Harold Greaseworthy',

replyTo: '[email protected]',

}).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[][email protected][][email protected] Note that recipients passed in this parameter will be visible as part of the message.

'[email protected]'
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,\n' +
  "Thanks 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" +
  '\n' +
  'Sincerely,\n' +
  'The 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

'[email protected]'
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,\n' +
  "Thanks 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" +
  '\n' +
  'Sincerely,\n' +
  'The 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

'[email protected]'

Exits

error

An unexpected error occurred.

success

OK.

'{"message":"success"}'