'am finding this error in my node express application its saying a function have named it sendMailer is not a function. this is when i trigger sent
that is the error now its saying that sendEmail function is not a function have done everything even changing the function format but its saying same error have been doing this the whole day with any solution that have gotten let me give the code of the function
async function sendEmail(emailOptions) {
try{
let emailTransporter = createTransporter();
emailTransporter.sendMail(emailOptions);
}catch(err){
console.log(err)
}
};
module.exports = sendEmail
where am declaring the function.. am calling it in another file where i add some parameters in the function as seen in the code below
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;
Solution 1:[1]
This type of export function is for arrow functions.
You should export function as follows:
module.exports = sendEmail();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mohammad Heidary |

