{"size": 821, "ext": "js", "max_stars_repo_path": "helpers/email.js", "max_stars_repo_name": "DevangML/Ultimate-MERN-Project", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "helpers/email.js", "max_issues_repo_name": "DevangML/Ultimate-MERN-Project", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "helpers/email.js", "max_forks_repo_name": "DevangML/Ultimate-MERN-Project", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.4838709677, "max_line_length": 102, "alphanum_fraction": 0.6126674787}
const nodeMailer = require('nodemailer');
const logger = require('../logs/logger');
require('path');
require('dotenv').config({ path: '.env' });

exports.sendEmailWithNodemailer = (req, res, emailData) => {
  const transporter = nodeMailer.createTransport({
    host: 'smtp.gmail.com',
    port: 587,
    secure: false,
    requireTLS: true,
    auth: {
      user: 'devangmanjramkar@gmail.com',
      pass: process.env.MAIL_PWD,
    },
    tls: {
      ciphers: 'SSLv3',
    },
  });

  return transporter
    .sendMail(emailData)
    .then((info) => {
      console.log(`Message sent: ${info.response}`);
      return res.json({
        message: `Email has been sent to your email. Follow the instruction to activate your account`,
      });
    })
    .catch((err) => console.log(`Problem sending email: ${err}`));
};
