Skip to content

nathyecomp/sendgrid-parse

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

SendGrid-Parse

A SendGrid Cloud Code module with X-SMTPAPI Support.

Installation

*Should soon be available in Cloud Code's env.

Example

var sendgrid = require('sendgrid');
sendgrid.initialize('SENDGRID-USERNAME', 'SENDGRID-PASSOWORD');

sendgrid.sendEmail({
	to: 'john@email.com',
	from: 'doe@email.com',
	subject: 'Hello!',
	text: 'Hello again!'
}, {
    success: function(httpResponse) {
        console.log(httpResponse);
        response.success("Email sent!");
    },
    error: function(httpResponse) {
        console.error(httpResponse);
        response.error("Uh oh, something went wrong");
    }
});

Create Email Object

var sendgrid = require('sendgrid');
var email = sendgrid.Email({to: ['john@email', 'doe@email.com']});
var otherEmail = sendgrid.Email();

Adding Recipients

email.addTo('jose@email.com');
email.addTo(['jose2@email.com', 'happy@email.com']);

Adding ToName

email.addToName('Jose');
email.addToName(['Jose 2', 'Happy']);

Setting From

email.setFrom('joseph@email.com');

Setting FromName

email.setFromName('Joseph');

Setting Subject

email.setSubject('subject');

Setting Text

email.setText('this text');

Setting HTML

email.setHTML('<b>that html</b>');

Adding BCC Recipients

email.addBcc('jose@email.com');
email.addBcc(['jose2@email.com', 'happy@email.com']);

Setting Reply To

email.setReplyTo('email@email.com');

Setting Date

email.setDate(new Date().toUTCString());

Adding Files

// Parse.File Object
email.addFile('filename', file).then(function(e) {
    console.log(e);
});
// or
email.addFileFromBuffer('filename', buffer);
// or
email.addFileFromStream('filename', str);

Setting Header

email.setHeaders('some header');

Setting SMTPAPI Header

email.setAPIHeader('{sub:{key:value}}');

SendGrid's X-SMTPAPI

email.addSubstitution('key', 'value')
email.addSection('section', 'value')
email.addCategory('category')
email.addUniqueArg('key', 'value')
email.addFilter('filter', 'setting', 'value')

MIT License

About

SendGrid Parse Cloud Module

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%