A SendGrid CommonJS module for Titanium
JavaScript Python CSS Makefile
Latest commit 3ea5eed Apr 28, 2016 @thinkingserious thinkingserious Update README.md
Permalink
Failed to load latest commit information.
app JSHint test passed. Fixed typo on constructor file handler Apr 10, 2014
plugins/ti.alloy first commit Feb 19, 2014
.gitignore Added gitignore Mar 5, 2014
LICENSE first commit Feb 19, 2014
Makefile first commit Feb 19, 2014
README.md Update README.md Apr 28, 2016
tiapp.xml version bump Apr 7, 2014

README.md

IMPORTANT ANNOUNCEMENT

As of May 1, 2016, SendGrid will no longer support this library.

Please direct any questions to the Developer Experience team.

Titanium SendGrid

A SendGrid CommonJS library for Titanium

Simple CommonJS library to be used in Titanium projects in order to send emails through SendGrid's Web API.

Installation

Titanium IDE:

  • Copy tisendgrid.js into your lib folder.

Gittio:

  • TODO

Example

var sendgrid = require('tisendgrid')('SENDGRID-USERNAME', 'SENDGRID-PASSOWORD');
sendgrid.send({
	to: 'john@email.com',
	from: 'doe@email.com',
	subject: 'Hello!',
	text: 'Hello again!'
}, function (e) {
	if (e) {
		console.log(e); // Email wasn't sent
	}
});

Create Email Object

var sendgrid = require('tisendgrid')('SENDGRID-USERNAME', 'SENDGRID-PASSOWORD');
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

// Filename parameter is optional
email.addFile('./filepath/file', 'filename');
email.addFile(file); // Titanium.Filesystem.File

Setting Header

email.setHeader('some header');

Setting SMTPAPI Header

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

SendGrid's X-SMTPAPI

Substitution

email.addSubstitution('key', 'value')

Section

email.addSection('section', 'value')

Category

email.addCategory('category')

Unique Arguments

email.addUniqueArg('key', 'value')

Filter

email.addFilter('filter', 'setting', 'value')

MIT License

Notes

Thanks to Ricardo Alcocer for the initial work! Pull requests are more than welcomed!