I have using nodemailer to send emial notification in my system, and it works perfect before this week. I got an error said cannot use IPV4 address with current network
{ Error: Can not use IPv4 addresses with current network
at GetAddrInfoReqWrap.dns.lookup [as callback] (/home/****/backend/node_modules/nodemailer/lib/shared/index.js:203:35)
at GetAddrInfoReqWrap.onlookupall [as oncomplete] (dns.js:80:8) code: 'EDNS', command: 'CONN' }
Some info related to my system and application:
System: Ubuntu 22.04.
Backend: express.js.
Node.js version: 10.19.0.
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: '**',
pass: '**',
},
});
function sendEmail(to, subject, text, html) {
transporter.sendMail({
from: '"Server - donotreply" <mailto:*******@gmail.com>', // sender address
to: to, // list of receivers
subject: subject, // Subject line
text: text, // plain text body
html: html, // html body
}).then(info => {
console.log({info});
}).catch(console.error);
}
I have no idea what is going on, can anyone please provide some info that can helps me figure out. thanks a lot
i have ried to restart the application and reboot the system, but the problem still exist.
2
Answers
I haven't found answer for the problem, but i found a posible solusion to solve it.
Try reinstall the nodemailer - use
npm install all
It works for me
I was facing the same problem only on Windows and when the internet connexion of the computer was sharing from a smartphone.
In my side, the latest working
nodemailer
version was 6.7.3.This issue was fixed in
nodemailer
6.9.0 released on the 12 january 2023.For me, the accepted solution does not works until the
nodemailer
v6.9.0 release in january..So, the correct fix will be to update
nodemailer
to v6.9.0 or upper.