Created
April 7, 2014 16:34
-
-
Save elbuo8/10023719 to your computer and use it in GitHub Desktop.
ti.sendgrid blog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sendgrid = require('tisendgrid')('SENDGRID-USERNAME', 'SENDGRID-PASSOWORD'); | |
sendgrid.send({ | |
to: '[email protected]', | |
from: '[email protected]', | |
subject: 'Hello!', | |
text: 'Hello again!' | |
}, function (e) { | |
if (e) { | |
console.log(e); // Email wasn't sent | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sendgrid = require('tisendgrid')('SENDGRID-USERNAME', 'SENDGRID-PASSOWORD'); | |
var email = sendgrid.Email({ | |
to: '[email protected]', | |
from: '[email protected]', | |
subject: 'Welcome!', | |
text: 'This is inside of the template!' | |
}); | |
email.addFilter('template', 'enable', 1); | |
email.addFilter('template', 'text/html', | |
'<html><body>General template stuff.<% body %></body></html>'); | |
sendgrid.send(email, function (e) { | |
if (e) { | |
console.log('Oups :( : ' + e); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am developing an app with Titanium Studio, build: 3.4.1.201410281727 where users need to signup and am trying to use sendgrid to send emails to users but without success. I have signed up at sendgrid and have a userid and password that I am using at the xxxxxxx below. I am testing this with xampp locally and with ipage hosted account. The code runs up to where it says "Message Sent" and then gives an error as follows. "Application Error Uncaught Syntax Error: Unexpected end of input at line / (Line 1)"
Please see if you can help me out.
Thank you in advance.
Jephta.
Here is the code i am using:
var api_user = "xxxxxxxx";
var api_key = "xxxxxxxx"
var fromEmail = "[email protected]";
var theSubject = "Hello";
var theBody = "Hello from Jephta";
var sendgrid = require("tisendgrid")(api_user, api_key);
var email = {
to: emailAddress.value,
from: fromEmail,
subject: theSubject,
text: theBody
};
var message = sendgrid.Email(email);
sendgrid.send(message, function(e) {
if (e) {
alert(e.errors[0]);
} else {
alert("Message sent");
}
});