HTML emails, fixes formatting

This commit is contained in:
Ben Ramey
2014-07-04 14:55:20 -05:00
parent 353ffcf8dd
commit 303254ce9d
4 changed files with 38 additions and 16 deletions

View File

@@ -1,5 +1,6 @@
// EmailService.js
var sendgrid = require("sendgrid");
var thenJade = require("then-jade");
exports.sendOrderEmail = function(inviteeData) {
Run.findOne({ id: inviteeData.run_id }, function(err, runData) {
@@ -8,29 +9,36 @@ exports.sendOrderEmail = function(inviteeData) {
return;
}
var emailText = "You've been invited to " + runData.creatorName + "'s lunch run: '"
+ runData.name + "'! \n\n Put in your order here:\nhttp://www.lunchrun.me/#/order/"
+ inviteeData.id;
var options = {
fromname: runData.creatorName + " via LunchRun.me",
from: sails.config.email.fromAddress,
to: inviteeData.email,
toname: inviteeData.name,
subject: "You've been invited to a lunch run!",
replyto: runData.creatorEmail,
text: emailText
replyto: runData.creatorEmail
};
var sg = sendgrid(sails.config.email.apiUser, sails.config.email.apiKey);
sg.send(options, function(err, response) {
if (err) {
console.log(err);
} else {
console.log("message sent from: " + runData.creatorEmail + ", to: " + inviteeData.email);
}
});
thenJade.renderFile(
'./views/emails/new-invitee.jade',
{ runData: runData, inviteeData: inviteeData },
function(err, result) {
if (err) {
console.log(err);
return;
}
console.log(options);
options.html = result;
var sg = sendgrid(sails.config.email.apiUser, sails.config.email.apiKey);
sg.send(options, function(err, response) {
if (err) {
console.log(err);
} else {
console.log("message sent from: " + runData.creatorEmail + ", to: " + inviteeData.email);
}
});
console.log(options);
});
});
};