HTML emails, fixes formatting
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -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
6
views/emails/layout.jade
Normal file
@@ -0,0 +1,6 @@
|
||||
doctype html
|
||||
|
||||
html(lang="en")
|
||||
head
|
||||
body
|
||||
block content
|
||||
8
views/emails/new-invitee.jade
Normal file
8
views/emails/new-invitee.jade
Normal 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!
|
||||
|
||||
Reference in New Issue
Block a user