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,21 +9,27 @@ 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);
thenJade.renderFile(
'./views/emails/new-invitee.jade',
{ runData: runData, inviteeData: inviteeData },
function(err, result) {
if (err) {
console.log(err);
return;
}
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);
@@ -33,4 +40,5 @@ exports.sendOrderEmail = function(inviteeData) {
console.log(options);
});
});
};

View File

@@ -4,5 +4,5 @@
module.exports.email = {
apiUser: "benjaminramey",
apiKey: "AVidasUPthub6pY3fFGe",
fromAddress: "ben.ramey@gmail.com"
fromAddress: "no-reply@lunchrun.me"
};

6
views/emails/layout.jade Normal file
View File

@@ -0,0 +1,6 @@
doctype html
html(lang="en")
head
body
block content

View File

@@ -0,0 +1,8 @@
extends layout
block content
p= "You've been invited to " + runData.creatorName + "'s lunch run: " + runData.name + "!"
p
a(href='http://www.lunchrun.me/#/order/' + inviteeData.id) Put in your order!