diff --git a/lib/utils/mailer.js b/lib/utils/mailer.js index 55ffc73..3c5d3c6 100644 --- a/lib/utils/mailer.js +++ b/lib/utils/mailer.js @@ -1,9 +1,13 @@ var Promise = require( 'bluebird' ) , config = require( 'config' ) - , sendgrid = require( 'sendgrid' )( config.sendgrid.apiUser, config.sendgrid.apiKey ); + , sendgrid; -module.exports = { +module.exports = { send: function( payload ) { + if ( !sendgrid ) { + sendgrid = require( 'sendgrid' )( config.sendgrid.apiUser, config.sendgrid.apiKey ); + } + return new Promise( function( resolve, reject ) { sendgrid.send( payload, function( err, res ) { if ( !err ) {