/////////////////////////////////////////////////
// LOGGING
/////////////////////////////////////////////////
const logger = require("../public/js/app/logger");
// ENVOIE MAIL GOOGLE MAIL
const nodemailer = require('nodemailer');


function envoie_mail(mailOptions) {
    logger.info("MAIL ENVOI AVANT");
    var transporter = nodemailer.createTransport({
        service: 'gmail',
        auth: {
          user: process.env.nodemailer_user,
          pass: process.env.nodemailer_pass
        }
    });
    
    transporter.sendMail(mailOptions, function(error, info){
        if (error) {
        logger.info("error" + error);
        } else {
        logger.info("Email envoyé: " + info.response);
        }
    });
    logger.info("MAIL ENVOI APRES");
}

module.exports = {
    envoie_mail
}