"use strict";

var _nodemailer = _interopRequireDefault(require("nodemailer"));

var _index = require("./index");

var _jsonHelper = require("./jsonHelper");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

if (process.argv.length <= 6) {
  (0, _index.log)('Usage: node mailSender <from> <pass> <to> <subject> <html>');
  process.exit(-1);
}

let [from, pass, to, subject, html, cc, user, reportURL] = process.argv.slice(2);
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'Report_URL', reportURL);

let transporter = _nodemailer.default.createTransport({
  host: 'smtp.tsi.zohocorpin.com',
  port: 25,
  secure: false,
  auth: {
    user,
    pass
  }
});

let mailOptions = {
  from: from,
  to: to,
  cc: cc,
  subject: subject,
  html: html
};
transporter.sendMail(mailOptions, (error, info) => {
  if (error) {
    (0, _index.log)(error);
  } else {
    (0, _index.log)(`Email sent: ${info.response}`);
  }
});