From acd47767d0c02dfa1a4152208a16c21255e4943b Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 22 Sep 2016 10:11:19 -0700 Subject: Upgrade sendgrid and fill in transaction details in notification email --- routes/users.js | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'routes/users.js') diff --git a/routes/users.js b/routes/users.js index 1449eb02..2c79cb31 100644 --- a/routes/users.js +++ b/routes/users.js @@ -154,15 +154,20 @@ return global.css; }) }, function(err, html) { - var email, sendgrid; - sendgrid = require('sendgrid')(config.sendgrid_user, config.sendgrid_password); - email = new sendgrid.Email({ - to: req.body.email, - from: 'adam@coinos.io', - subject: 'Welcome to CoinOS', - html: html + var content, from_email, helper, mail, sg, subject, to_email; + helper = require('sendgrid').mail; + from_email = new helper.Email('info@coinos.io'); + to_email = new helper.Email(req.body.email); + subject = 'Welcome to CoinOS'; + content = new helper.Content('text/html', html); + mail = new helper.Mail(from_email, subject, to_email, content); + sg = require('sendgrid')(config.sendgrid_token); + request = sg.emptyRequest({ + method: 'POST', + path: '/v3/mail/send', + body: mail.toJSON() }); - return sendgrid.send(email); + return sg.API(request); }); }); }); @@ -232,15 +237,20 @@ return global.css; }) }, function(err, html) { - var email, sendgrid; - sendgrid = require('sendgrid')(config.sendgrid_user, config.sendgrid_password); - email = new sendgrid.Email({ - to: req.body.email, - from: 'adam@coinos.io', - subject: 'CoinOS Wallet Key', - html: html + var content, from_email, helper, mail, sg, subject, to_email; + helper = require('sendgrid').mail; + from_email = new helper.Email('info@coinos.io'); + to_email = new helper.Email(req.body.email); + subject = 'CoinOS Wallet Key'; + content = new helper.Content('text/html', html); + mail = new helper.Mail(from_email, subject, to_email, content); + sg = require('sendgrid')(config.sendgrid_token); + request = sg.emptyRequest({ + method: 'POST', + path: '/v3/mail/send', + body: mail.toJSON() }); - return sendgrid.send(email); + return sg.API(request); }); } }, -- cgit v1.2.3