const nodemailer = require("nodemailer");


function setup() {
  return nodemailer.createTransport({
    host: process.env.EMAIL_SERVER,
    port: process.env.EMAIL_PORT,
    auth: {
      user: process.env.EMAIL_USERNAME,
      pass: process.env.EMAIL_PASSWORD
    }
  });
}

 exports.sendEmail = function(text,nom,prenom,tel,mail) {
  const tranport = setup();
  const email = {
    from: process.env.EMAIL_FROM,
    to: "contact@talentstube.com",
    subject: "PWA feedback 💌⚡️",
    text: `
    Hello Team,
    A new user sent a feedback 👌:
--->
    ${text}

    nom: ${nom}
    prenom:${prenom}
    mail:${mail}
    tel:${tel}

<---
    Have a nice day !
    - e-declic Team PWA

    `
  };

  tranport.sendMail(email);
}
