I'm trying to send a mail to an email address with nodemailer + mailtrap, but i'm receving the mail in the mailtrap account... why is this happening?
here's my code:
const transport = nodemailer.createTransport({
host: "smtp.mailtrap.io",
port: 2525,
auth: {
user: "79a422a4c8485b",
pass: "492900f98e999e",
},
});
app.get("/sendMail", function (req, res) {
const rand = Math.floor(Math.random() * 100 + 54);
const link = `http://localhost:5000/verify?id=${rand}`;
const mailOptions = {
from: "sender@server.com",
to: req.query.to, // DESTINY MAIL, BUT NO MATTER WHAT I PUT IN HERE, I ONLY RECEIVE THE MAIL
// ON THE MAILTRAP ACCOUNT!
subject: "Hello ✔",
text: "Hello world ✔",
html: `Hello,<br> Please Click on the link to verify your email.<br><a href=${link}>Click here to verify</a>`,
};
console.log(mailOptions);
// smtpTransport.sendMail();
transport.sendMail(mailOptions, function (error: any, response: any) {
if (error) {
console.log("no se pudo mandar el mail porque ->", error);
res.end("error");
} else {
console.log("response", response);
console.log(`Message sent: ${response.message}`);
res.send("done");
}
});
});
What am i doing wrong?