Skip to content

Instantly share code, notes, and snippets.

@AkarshSatija
Created June 6, 2017 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AkarshSatija/2069446196f9eca590c0be4e55cd165c to your computer and use it in GitHub Desktop.
Save AkarshSatija/2069446196f9eca590c0be4e55cd165c to your computer and use it in GitHub Desktop.
var sendgrid = require('sendgrid')(config.sendgridMailer.auth.key);
exports.bookMarkedArticle = function (req,res,cb) {
async.waterfall([
function(done) {
res.render('bookmarks/bookmark-invite', {
name: req.user.firstName,
article: req.article
}, function(err, emailHTML) {
done(err, emailHTML, req.user);
});
},
// If valid email, send reset email using service
function(emailHTML, user, done) {
var email = new sendgrid.Email();
email.addTo(user.email);
email.setFrom(config.sendgridMailer.from_email);
email.setFromName(config.sendgridMailer.from_name);
email.setSubject(user.firstName+ ', your LBB is ready');
email.setHtml(emailHTML);
email.addHeader('X-Sent-Using', 'SendGrid-API');
email.addHeader('X-Transport', 'web');
sendgrid.send(email, function(err, json) {
if (err) {
cb(err);
}
cb('An email has been sent to ' + user.email + ' with further instructions.')
});
}
], function(err) {
if (err) cb(err);
});
}
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<p>Dear {{name}},</p>
<p>
Thanks for adding <b>{{article.title}}</b> to your LBB - It's waiting for you on our app, get it now:
</p>
<p>
<a href="http://j.mp/LBB-Android" title="" class="" target="_blank" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #fff;">
<img alt="" src="https://gallery.mailchimp.com/95272f0ed4f83a02e57b62922/images/4e8d2785-0bdd-483b-99cc-407131c717ff.png" width="150" style="max-width: 150px;border: 0;height: auto;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;vertical-align: bottom;" class="mcnImage">
</a>
<a href="http://j.mp/LBB-IPhone" title="" class="" target="_blank" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;margin-left:10px">
<img alt="" src="https://gallery.mailchimp.com/95272f0ed4f83a02e57b62922/images/b5e74e44-6bb9-4d32-a209-a0a9a7910c56.png" width="150" style="max-width: 150px;border: 0;height: auto;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;vertical-align: bottom;" class="mcnImage">
</a>
</p>
<br>
<p>Enjoy creating your own Little Black Book!</p>
<p>With &lt;3 from the Team LBB</p>
<p>P.s. if you need any help, please write to us at techcrew@lbb.in</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment