Skip to content

Commit

Permalink
Properly handle misconfigured email service
Browse files Browse the repository at this point in the history
  • Loading branch information
ericf committed Oct 12, 2013
1 parent a10bd18 commit 8dd1845
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ config = {
invitationSecret: env.INVITATION_SECRET,

mailgun: {
endpint: env.MAILGUN_API_SERVER + '/',
endpint: env.MAILGUN_API_SERVER && (env.MAILGUN_API_SERVER + '/'),
domain : env.MAILGUN_DOMAIN,
secret : env.MAILGUN_API_KEY
},
Expand Down
4 changes: 4 additions & 0 deletions lib/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ hbs = exphbs.create({
});

function send(to, subject, body, callback) {
if (!(mailgun.endpint && mailgun.domain && mailgun.secret)) {
return callback(new Error('Email service not properly configured.'));
}

var url = mailgun.endpint + path.join(mailgun.domain, 'messages');

request.post(url, {
Expand Down

0 comments on commit 8dd1845

Please sign in to comment.