/**
 * @file emailService.js
 * @author Radim Buráň (xburan03@stud.fit.vutbr.cz)
 */

const nodemailer = require('nodemailer');
require('dotenv').config();

const transporter = nodemailer.createTransport({
    sendmail: true,
    newline: "unix",
    path: "/usr/sbin/sendmail"
});

const sendEmail = (email, subject, content) => {
    let mailOptions = {
        from: "flowerpot@example.com",
        to: email,
        subject: subject,
        text: content
    };

    transporter.sendMail(mailOptions, (err, info) => {
        if (err) {
            console.error("ERROR Email send | To: " + email + " | Error: " + err);
        } else {
            console.log("Email send | To: " + email + " | Status: " + info.response);
        }
    });
}

module.exports = {
    sendEmail
}

