summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/sendgrid.js13
-rw-r--r--test.js37
2 files changed, 49 insertions, 1 deletions
diff --git a/lib/sendgrid.js b/lib/sendgrid.js
index 122a1a9..d5aed75 100644
--- a/lib/sendgrid.js
+++ b/lib/sendgrid.js
@@ -27,6 +27,7 @@ SendGrid.prototype.send = function(email, callback) {
'Content-Length': post_data.length
}
};
+ console.dir(post_data);
var request = https.request(options, function(res) {
res.setEncoding('utf8');
@@ -52,13 +53,19 @@ SendGrid.prototype.smtp = function(email, callback) {
};
email = email.params || email;
+ console.log('\t\t\t' + JSON.stringify(email['x-smtpapi'])
+);
nodemailer.send_mail({
sender: email.from,
to: email.to,
subject: email.subject,
body: email.text,
- html: email.html
+ html: email.html,
+ headers: {
+ "x-smtpapi": JSON.stringify(email['x-smtpapi'])
+ },
+ debug:true
}, function(error, success) {
callback.call(self, success, error);
});
@@ -70,7 +77,11 @@ SendGrid.prototype.getPostData = function(params) {
api_user: this.api_user,
api_key: this.api_key
}
+ console.log('\n\n\n\nhere is logging params');
_(params).each(function(v, k) {
+ console.log("value is %s and key is %s -> %s", v, k, _(v).isObject() );
+ if (_(v).isObject() && !_(v).isDate() && !_(v).isArray())
+ v = JSON.stringify(v);
data[k] = v;
});
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..eb0987a
--- /dev/null
+++ b/test.js
@@ -0,0 +1,37 @@
+var SendGrid = require('./lib/sendgrid');
+var Email = require('./lib/email');
+console.log(require('./lib/sendgrid'));
+console.log(SendGrid);
+console.log(Email);
+
+var sender = new SendGrid({api_user: 'siyegen', api_key: 'supermailsforus'});
+var email = new Email({
+ from: 'testy@testerson.com',
+ to: 'david.tomberlin@sendgrid.com',
+ subject: 'Simple mailer ',
+ text: 'oh yeah man, for real ✔ 3 tests complete (',
+ html: '<b>oh</b> yeah man, for <i>reaaaaaaal</i> ✔ 3 tests complete ('
+});
+
+var x_smtpapi = {};
+
+x_smtpapi.to = ["david.tomberlin@sendgrid.com"];
+email.params["x-smtpapi"] = x_smtpapi;
+email.params["x-smtpapi"].filters = {
+ "footer": {
+ "settings": {
+ "enable": 1,
+ "text/plain" : "THIS IS A FOOTERS, for real ✔ 3 tests complete (",
+ "text/html" : "THIS IS A FOOTERS \u00a2, for real ✔ 3 tests complete ("
+ }
+ }
+};
+console.dir(email.params['x-smtpapi']);
+console.log(email);
+
+sender.smtp(email, function(success, err) {
+ if(success) console.log('Email sent');
+ else console.log(err);
+});
+
+