IMPORTANT ANNOUNCEMENT
As of May 1, 2016, SendGrid will no longer support this library.
Please direct any questions to the Developer Experience team.
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.
Titanium IDE:
- Copy tisendgrid.js into your lib folder.
Gittio:
- TODO
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
}
});var sendgrid = require('tisendgrid')('SENDGRID-USERNAME', 'SENDGRID-PASSOWORD');
var email = sendgrid.Email({to: ['john@email', 'doe@email.com']});
var otherEmail = sendgrid.Email();email.addTo('jose@email.com');
email.addTo(['jose2@email.com', 'happy@email.com']);email.addToName('Jose');
email.addToName(['Jose 2', 'Happy']);email.setFrom('joseph@email.com');email.setFromName('Joseph');email.setSubject('subject');email.setText('this text');email.setHTML('<b>that html</b>');email.addBcc('jose@email.com');
email.addBcc(['jose2@email.com', 'happy@email.com']);email.setReplyTo('email@email.com');email.setDate(new Date().toUTCString());// Filename parameter is optional
email.addFile('./filepath/file', 'filename');
email.addFile(file); // Titanium.Filesystem.Fileemail.setHeader('some 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')Thanks to Ricardo Alcocer for the initial work! Pull requests are more than welcomed!