I have setup local smtp server in my linux machine. The following command works and successfully received mail from test@<machine-name>.
echo “THIS IS A TEST EMAIL” | mail -s "This is subject" xxxx@gmail.com
Whereas I need to send mail using nodemailer
which I have configured as below,
const transporter = nodemailer.createTransport({
host:"smtp.<ourserver>.com",
secure:false
});
const info = await transporter.sendMail({
from: 'test@<machine-name>', // sender address
to: 'xxxx@gmail.com', // list of receivers
subject: "Hello", // Subject line
html: "<i>Hello world</i>" // html body
});
But I am getting the following error,
Any idea why I am facing this issue?
I have seen similar questions posted in quora but none of them solved my problem.
With emailjs, it works with the following config,
const { SMTPClient } = require('emailjs');
const client = new SMTPClient({
host: 'smtp.<ourserver>.com',
ssl: false,
tls: false
});
client.send(
{
text: 'Hello',
from: 'test@<machine-name>',
to: 'xxx@gmail.com',
subject: 'Hello',
},
(err, message) => {
//
}
);
How can I make it work using nodemailer
?