Skip to content

Commit

Permalink
fix: prevent hitting mailgun API in testing env
Browse files Browse the repository at this point in the history
  • Loading branch information
adekbadek committed Feb 25, 2018
1 parent fcf1c15 commit 8901fe1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/mailer/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
const nodemailer = require('nodemailer')
const mg = require('nodemailer-mailgun-transport')

const isTest = process.env.NODE_ENV === 'test'

const auth = {
auth: {
api_key: process.env.MAILGUN_API_KEY,
domain: process.env.MAILGUN_DOMAIN,
},
}

const nodemailerMailgun = nodemailer.createTransport(mg(auth))
const nodemailerMailgun = !isTest && nodemailer.createTransport(mg(auth))

const send = ({to, authkey}) => {
if (isTest) {
return
}
nodemailerMailgun.sendMail({
from: `myemail@${process.env.MAILGUN_DOMAIN}`,
to,
Expand Down

0 comments on commit 8901fe1

Please sign in to comment.