esackbauer
I am trying ports 25 and 587.
When I try port 465, it also gives me an error about a self-signed certificate.
However, all ports work fine if I use
tls: {
rejectUnauthorized: false,
Below is my entire code:
`
const nodemailer = require(‘nodemailer’);
let transport = nodemailer.createTransport({
host: ‘192.168.1.1’,
port: 587,
auth: {
user: ‘user@example.com’,
pass: ‘yourpassword’
},
tls: {
rejectUnauthorized: false,
}
});
const message = {
from: ‘user@example.com’, // Sender address
to: ‘recipient@example.com’, // List of recipients
subject: ‘Mail works’, // Subject line
text: ‘This mail is coming from a new server, and we are using new credentials. Everything is working fine.’ // Plain text body
};
transport.sendMail(message, function (err, info) {
if (err) {
console.log(err);
} else {
console.log(info);
}
});
`
Why do I need to add this line rejectUnauthorized: false
? Can’t it work directly?