summaryrefslogtreecommitdiffstats
path: root/lib/sendgrid.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sendgrid.js')
-rw-r--r--lib/sendgrid.js18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/sendgrid.js b/lib/sendgrid.js
index c7fc0b7..12c8b85 100644
--- a/lib/sendgrid.js
+++ b/lib/sendgrid.js
@@ -27,9 +27,11 @@ function SendGrid(api_user, api_key) {
* @param {Email|Object} email An email object or a hash that has
* the values for the email to be sent.
* @param {Function} callback A function to call when the processing is done.
+ * This parameter is optional.
*/
SendGrid.prototype.send = function(email, callback) {
- var self = this;
+ var self = this
+ , cb = callback || function() { };
var boundary = Math.random();
@@ -71,7 +73,7 @@ SendGrid.prototype.send = function(email, callback) {
});
res.on('end', function() {
var json = JSON.parse(content);
- callback(json.message == 'success', json.errors);
+ cb(json.message == 'success', json.errors);
});
});
@@ -93,7 +95,7 @@ SendGrid.prototype.send = function(email, callback) {
if (success) {
send_rest();
} else {
- callback(false, message);
+ cb(false, message);
}
});
} else {
@@ -108,10 +110,12 @@ SendGrid.prototype.send = function(email, callback) {
* @param {Email|Object} email An email object or a hash that has
* the values for the email to be sent.
* @param {Function} callback A function to call when the processing is done.
+ * This parameter is optional.
*/
SendGrid.prototype.smtp = function(email, callback) {
var self = this
- , smtpTransport;
+ , smtpTransport
+ , cb = callback || function() { };
// SMTP settings
smtpTransport = nodemailer.createTransport("SMTP", {
@@ -126,9 +130,9 @@ SendGrid.prototype.smtp = function(email, callback) {
smtpTransport.sendMail(email.toSmtpFormat(), function(error, response) {
smtpTransport.close();
if(error) {
- return callback(false, response);
+ return cb(false, response);
}
- return callback(true, response);
+ return cb(true, response);
});
}
@@ -141,7 +145,7 @@ SendGrid.prototype.smtp = function(email, callback) {
if (success) {
send_smtp();
} else {
- callback(false, message);
+ cb(false, message);
}
});
} else {