const Mailer = require('nodemailer');

function sendMail (options, callback) {
  // create reusable transporter object using the default SMTP transport
  let transporter = Mailer.createTransport({
      host: 'mail.fitz.guru',
      port: 587,
      secure: false, // secure:true for port 465, secure:false for port 587
      auth: {
          user: 'support@fitz.guru',
          pass: 'NotSt@ff3d!'
      }
  });

  callback = typeof callback === 'function' ? callback : (error, info) => {
    if (error) {
      return console.error(error);
    }

    console.debug('Message %s sent: %s', info.messageId, info.response);
  };

  // send mail with defined transport object
  transporter.sendMail(options, callback);
}

module.exports = {
  
  send: (email, callback) => {
    sendMail(mail, callback);
  }
};