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 --- src/routes/users.coffee | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'src/routes/users.coffee') diff --git a/src/routes/users.coffee b/src/routes/users.coffee index e682602b..d1c8f602 100644 --- a/src/routes/users.coffee +++ b/src/routes/users.coffee @@ -112,16 +112,22 @@ module.exports = (sessions) -> js: (-> global.js), css: (-> global.css), (err, html) -> - 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 + 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() ) - sendgrid.send(email) + sg.API(request) ) ) ) @@ -178,16 +184,21 @@ module.exports = (sessions) -> js: (-> global.js), css: (-> global.css), (err, html) -> - 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 + 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() ) - sendgrid.send(email) + sg.API(request) ) verify: (req, res) -> -- cgit v1.2.3