I'm using nodemailer like this:
const from = "info@my_domain.com";
const to = 'some_mail@gmail.com';
const subject = 'my subject';
const html = '<b>Hello world</b>';
const smtpOptions = {
"host": "mail.my_domain.com",
"port": 587,
"secure": false,
"auth": {
"user": "info@my_domain.com",
"pass": "12345679"
},
}
const transporter = nodemailer.createTransport(smtpOptions);
try {
const a = await transporter.sendMail({
from,
to,
subject,
html
});
} catch (err) {
console.log(err);
}
and I get this error:
Error: self signed certificate at TLSSocket.onConnectSecure (node:_tls_wrap:1532:34) at TLSSocket.emit (node:events:527:28) at TLSSocket._finishInit (node:_tls_wrap:946:8) at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:727:12) { code: 'ESOCKET', command: 'CONN' }
although I have a valid ssl and after some research I came up with adding this line to the smtpOptions :
tls: {
rejectUnauthorized: false
}
Now I don't get the error but no email is send !
Why I get this error and How to fix this so that I can simply send emails ?