const nodemailer = require("nodemailer"); require("dotenv").config(); const transporter = nodemailer.createTransport({ service: "gmail", auth: { user: process.env.EMAIL_USER, pass: process.env.EMAIL_PASS, }, }); async function sendVerificationEmail(to, token) { const verificationUrl = `${process.env.CLIENT_URL}/users/verify-email/${token}`; const mailOptions = { from: `YomiTrack <${process.env.EMAIL_USER}>`, to, subject: "Verifica tu cuenta en YomiTrack", html: `
Haz clic en el siguiente enlace para verificar tu cuenta:
Verificar cuentaSi tú no solicitaste esta cuenta, puedes ignorar este mensaje.
`, }; return transporter.sendMail(mailOptions); } async function sendResetEmail(to, token, email) { const resetUrl = `${process.env.CLIENT_URL}/reset-password.html?token=${token}&email=${email}`; const html = `Haz clic en el siguiente enlace para restablecer tu contraseña:
${resetUrl} `; await transporter.sendMail({ from: `YomiTrack <${process.env.EMAIL_USER}>`, to, subject: 'Restablece tu contraseña', html }); } module.exports = { sendVerificationEmail, sendResetEmail };