ese es el error, ahora dice que la función sendEmail no es una función, he hecho todo, incluso cambiando el formato de la función, pero dice que el mismo error ha estado haciendo esto todo el día con cualquier solución que haya obtenido, déjeme dar el código de la función
async function sendEmail(emailOptions) { try{ let emailTransporter = createTransporter(); emailTransporter.sendMail(emailOptions); }catch(err){ console.log(err) } }; module.exports = sendEmaildonde estoy declarando la función ... la estoy llamando en otro archivo donde agrego algunos parámetros en la función como se ve en el código a continuación
const sendEmail = require('./nodemailer'); async function sendConfirmationEmail (url, email) { try { const emailOptions = { from: `" Perez Food Delivery" <${process.env.USER}> `, to: email, subject: "Comfirmation of account ", html: ` <div style= "max-width:600px; margin: 0 auto;"> <h1 style="text-align: center; color: #5f6368; padding-bottom: 20px; ">welcome!</h1> <p style=" margin: 0; font-size: 16px; "> </p> <div style="width: fit-content; margin: 40px auto; " ><a href="${url}" target="_blank" style=" font-size: 16px; font-family: Helvetica,Arial,sans-serif; color: #222; cursor:pointer; text-decoration: none; padding: 10px 20px; border: 2px solid #202124; background: #fcba1c; font-weight: 600; display: inline-block;">comfirm here</a></div> <p style=" margin-bottom:0; font-size: 16px;">please click thebutton to navigate back to the site: </p> <p style="text-align:center; margin:10px 0; font-size: 16px;"><a href="#" target="_blank" style="color: #FFA73B;">${url}</a></p> <p style=" font-size: 16px;">If this request is not made by you kindly ignore this mail..</p> <div> <p style=" font-size: 16px; padding: 30px 0; background: #ffd5a1; color: #5f6368; text-align: center;">with regards, Perez Food Delivery .</p> `, } await sendEmail(emailOptions); } catch (err) { console.log(err); } }; module.exports = sendConfirmationEmail;Este tipo de función de exportación es para funciones de flecha.
Debe exportar la función de la siguiente manera:
module.exports = sendEmail();