Skip to content

sendgrid/ti.sendgrid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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

MIT License

Notes

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

About

A SendGrid CommonJS module for Titanium

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •