lib/getTransport.js
function getTransport(options = {}) {
  return new Promise((resolve, reject) => {
    try {
      const defaultTransport = {
        type: 'direct',
        transportOptions: { debug: true }
      };
      const { transportObject = defaultTransport, } = options;
      const nodemailerTransporter = nodemailer.createTransport(transportMap[transportObject.type](transportObject.transportoptions));
      if (transportObject.type === 'stub') {
        const originalSendmail = nodemailerTransporter.sendMail;
        nodemailerTransporter.sendMail = (data, callback) => {
          (function(maildata, mailcallback, fn) {
            return fn.call(nodemailerTransporter, maildata, function(err, email_status) {
              email_status.response = email_status.response.toString();
              mailcallback(err, email_status);
            });
          })(data, callback, originalSendmail);
        };
      }
      nodemailerTransporter.use('compile', htmlToText());
      resolve(nodemailerTransporter);
    } catch (e) {
      reject(e);
    }
  });
}
function getTransport(options = {}) {
  return new Promise((resolve, reject) => {
    try {
      const defaultTransport = {
        type: 'direct',
        transportOptions: { debug: true }
      };
      const { transportObject = defaultTransport, } = options;
      const nodemailerTransporter = nodemailer.createTransport(transportMap[transportObject.type](transportObject.transportoptions));
      if (transportObject.type === 'stub') {
        const originalSendmail = nodemailerTransporter.sendMail;
        nodemailerTransporter.sendMail = (data, callback) => {
          (function(maildata, mailcallback, fn) {
            return fn.call(nodemailerTransporter, maildata, function(err, email_status) {
              email_status.response = email_status.response.toString();
              mailcallback(err, email_status);
            });
          })(data, callback, originalSendmail);
        };
      }
      nodemailerTransporter.use('compile', htmlToText());
      resolve(nodemailerTransporter);
    } catch (e) {
      reject(e);
    }
  });
}
function getTransport ( options = { } ) { return new Promise ( ( resolve , reject ) => { try { const defaultTransport = { type : 'direct' , transportOptions : { debug : true } } ; const { transportObject = defaultTransport , } = options ; const nodemailerTransporter = nodemailer . createTransport ( transportMap [ transportObject . type ] ( transportObject . transportoptions ) ) ; if ( transportObject . type === 'stub' ) { const originalSendmail = nodemailerTransporter . sendMail ; nodemailerTransporter . sendMail = ( data , callback ) => { ( function ( maildata , mailcallback , fn ) { return fn . call ( nodemailerTransporter , maildata , function ( err , email_status ) { email_status . response = email_status . response . toString ( ) ; mailcallback ( err , email_status ) ; } ) ; } ) ( data , callback , originalSendmail ) ; } ; } nodemailerTransporter . use ( 'compile' , htmlToText ( ) ) ; resolve ( nodemailerTransporter ) ; } catch ( e ) { reject ( e ) ; } } ) ; }
returns a node mailer transport based off of a json configuration

@param {any} [options={}]
@param {object} options.transportObject the json configuration for a node mailer transport
@param {string} options.transportObject.transportType [ses|direct|sendmail|smtp-pool|sendgrid|sendgridapi|mailgun|stub]
@param {object} options.transportObject.transportOptions options for a node mailer transport
@returns {promise} resolves a node mailer transport
returns a node mailer transport based off of a json configuration