Move from Mandrill to Sendgrid.
This commit is contained in:
parent
edd3a2fc54
commit
f9210edfc6
3 changed files with 28 additions and 40 deletions
|
@ -5,7 +5,7 @@
|
|||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": "^5.10.0",
|
||||
"node": "^6.0.0",
|
||||
"npm": "^3.8.5"
|
||||
},
|
||||
"scripts": {
|
||||
|
@ -51,17 +51,17 @@
|
|||
"koa-statsd": "~0.0.2",
|
||||
"koa-views": "~3.1.0",
|
||||
"koa-websocket": "~1.1.0",
|
||||
"mandrill-api": "~1.0.45",
|
||||
"mime-types": "~2.1.5",
|
||||
"moment": "~2.10.6",
|
||||
"mongodb-promisified": "~1.0.3",
|
||||
"node-fetch": "^1.3.2",
|
||||
"node-sass": "~3.3.0",
|
||||
"node-sass": "~3.6.0",
|
||||
"node-uuid": "~1.4.3",
|
||||
"passwords": "~1.3.0",
|
||||
"raven": "~0.8.1",
|
||||
"redis": "~1.0.0",
|
||||
"s3-upload-stream": "~1.0.7",
|
||||
"sendgrid": "^2.0.0",
|
||||
"statsy": "~0.2.0",
|
||||
"stripe": "~3.7.1",
|
||||
"swig": "~1.4.2"
|
||||
|
|
|
@ -5,8 +5,8 @@ import views from 'co-views';
|
|||
const render = views(__dirname + '/../views', { default: 'ejs'});
|
||||
import debugname from 'debug';
|
||||
const debug = debugname('hostr-web:auth');
|
||||
import { Mandrill } from 'mandrill-api/mandrill';
|
||||
const mandrill = new Mandrill(process.env.MANDRILL_KEY);
|
||||
import sendgridInit from 'sendgrid';
|
||||
const sendgrid = sendgridInit(process.env.SENDGRID_KEY);
|
||||
|
||||
export function* authenticate(email, password) {
|
||||
const Users = this.db.Users;
|
||||
|
@ -102,20 +102,16 @@ ${process.env.WEB_BASE_URL + '/activate/' + user.activationCode}
|
|||
|
||||
— Jonathan Cremin, Hostr Founder
|
||||
`;
|
||||
mandrill.messages.send({message: {
|
||||
const mail = new sendgrid.Email({
|
||||
to: user.email,
|
||||
from: 'jonathan@hostr.co',
|
||||
fromname: 'Jonathan from Hostr',
|
||||
html: html,
|
||||
text: text,
|
||||
subject: 'Welcome to Hostr',
|
||||
'from_email': 'jonathan@hostr.co',
|
||||
'from_name': 'Jonathan from Hostr',
|
||||
to: [{
|
||||
email: user.email,
|
||||
type: 'to',
|
||||
}],
|
||||
'tags': [
|
||||
'user-activation',
|
||||
],
|
||||
}});
|
||||
});
|
||||
mail.addCategory('activate');
|
||||
sendgrid.send(mail);
|
||||
}
|
||||
|
||||
|
||||
|
@ -134,20 +130,16 @@ export function* sendResetToken(email) {
|
|||
const text = `It seems you've forgotten your password :(
|
||||
Visit ${process.env.WEB_BASE_URL + '/forgot/' + token} to set a new one.
|
||||
`;
|
||||
mandrill.messages.send({message: {
|
||||
const mail = new sendgrid.Email({
|
||||
to: user.email,
|
||||
from: 'jonathan@hostr.co',
|
||||
fromname: 'Jonathan from Hostr',
|
||||
html: html,
|
||||
text: text,
|
||||
subject: 'Hostr Password Reset',
|
||||
'from_email': 'jonathan@hostr.co',
|
||||
'from_name': 'Jonathan from Hostr',
|
||||
to: [{
|
||||
email: user.email,
|
||||
type: 'to',
|
||||
}],
|
||||
'tags': [
|
||||
'password-reset',
|
||||
],
|
||||
}});
|
||||
});
|
||||
mail.addCategory('password-reset');
|
||||
sendgrid.send(mail);
|
||||
} else {
|
||||
throw new Error('There was an error looking up your email address.');
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ import views from 'co-views';
|
|||
const render = views(path.join(__dirname, '/../views'), { default: 'ejs'});
|
||||
import Stripe from 'stripe';
|
||||
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
|
||||
import { Mandrill } from 'mandrill-api/mandrill';
|
||||
const mandrill = new Mandrill(process.env.MANDRILL_KEY);
|
||||
import sendgridInit from 'sendgrid';
|
||||
const sendgrid = sendgridInit(process.env.SENDGRID_KEY);
|
||||
|
||||
const fromEmail = process.env.EMAIL_FROM;
|
||||
const fromName = process.env.EMAIL_NAME;
|
||||
|
@ -48,20 +48,16 @@ export function* create() {
|
|||
— Jonathan Cremin, Hostr Founder
|
||||
`;
|
||||
|
||||
mandrill.messages.send({message: {
|
||||
const mail = new sendgrid.Email({
|
||||
to: this.session.user.email,
|
||||
from: fromEmail,
|
||||
fromname: fromName,
|
||||
html: html,
|
||||
text: text,
|
||||
subject: 'Hostr Pro',
|
||||
'from_email': fromEmail,
|
||||
'from_name': fromName,
|
||||
to: [{
|
||||
email: this.session.user.email,
|
||||
type: 'to',
|
||||
}],
|
||||
'tags': [
|
||||
'pro-upgrade',
|
||||
],
|
||||
}});
|
||||
});
|
||||
mail.addCategory('pro-upgrade');
|
||||
sendgrid.send(mail);
|
||||
}
|
||||
|
||||
export function* cancel() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue