I am experiencing an unexpected behaviour from nodemailer:
here is my code:
let transporter = nodemailer.createTransport({
host: 'outlook.office365.com',
auth: {
user: process.env.MAIL_USER, // generated ethereal user
pass: process.env.MAIL_PASS, // generated ethereal password
},
tls: {
rejectUnauthorized: false
}});
let info = transporter.sendMail({
from: '"Mark "mymail@outlook.com',
to: "anothermailOfMine@gmail.com",
subject: "Hello ✔",
text: "Hello world?",
html: `<b>
<a href='http://localhost:3000/activate_user/${result._id}'>
<button>Activate
profile</button></a>
</b>`, // html body
});
transporter.sendMail(info, function (err, info) {
if (err) {
console.log(err);
res.json(err);
} else {
console.log(' mail sent');
res.json({success:true, message:''});
}})};
The sendMail method returns an error even if the mail is actually sent successfully, which means that the front-end never receives a positive response about the sending, that's the error i just mentioned:
Error: No recipients defined
at SMTPConnection._formatError
I wonder if I am doing something wrong.