Sending email : "Error can not use ipv4 addresses with current network"

Hello,

I'm sending emails with node-red-node-email. It worked well for some years until some days ;
I now have to following error "Error: Can not use IPv4 addresses with current network"

Here's the node configuration

[
    {
        "id": "5a4968db.acd258",
        "type": "e-mail",
        "z": "6ba9417c.86fd5",
        "server": "ssl0.ovh.net",
        "port": "465",
        "secure": true,
        "tls": true,
        "name": "xx@gmail.com",
        "dname": "",
        "x": 890,
        "y": 480,
        "wires": []
    }
]

nodered V3.0.1 is installed on an rpi.
I found nothing about this error crawling the web.

any idea ?

Thanks
Julien

What happens if you use the gmail server smtp.gmail.com?

Unfortunatey, I was unable to setup gmail as smtp server.
I have followed various instructions from the web (generated an app pwd...) but it's not successfull.
I always get ENETUNREACH error.

ENETUNREACH and the earlier error strongly imply your pi's network is broken.

ENETUNREACH means that the remote machine can not be reached, this most likely means that your pi does not have a IPv4 default route

arglll ! tried everything except reboot which did the trick!
Thanks a lot.

I am experiencing the same problem. I managed to get a test flow working a few weeks ago. Now, the flow gives the error: "Error: Can not use IPv4 addresses with current network"

Have tried restarting Node-Red; rebooting; upgrading to V3.0.2, completely powering down, removing the network cable to the RPi, etc. None of which appear to work.

Any suggestions much appreciated.

[
    {
        "id": "1079cc72cc79317d",
        "type": "tab",
        "label": "Outbound email",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "3d7cb306522e7148",
        "type": "e-mail",
        "z": "1079cc72cc79317d",
        "server": "smtp.ionos.co.uk",
        "port": "465",
        "secure": true,
        "tls": true,
        "name": "",
        "dname": "Node-red test email",
        "credentials": {},
        "x": 940,
        "y": 240,
        "wires": []
    },
    {
        "id": "a5f2999e0a316f94",
        "type": "function",
        "z": "1079cc72cc79317d",
        "name": "",
        "func": "\nmsg.payload = \"Test\";\nmsg.topic = \"This is a test email\";\nmsg.to = \"abc@dfe.com\";\n\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 580,
        "y": 240,
        "wires": [
            [
                "3d7cb306522e7148"
            ]
        ]
    },
    {
        "id": "64b7bf73da0f4b00",
        "type": "inject",
        "z": "1079cc72cc79317d",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 260,
        "y": 240,
        "wires": [
            [
                "a5f2999e0a316f94"
            ]
        ]
    },
    {
        "id": "fc361521d5c06297",
        "type": "comment",
        "z": "1079cc72cc79317d",
        "name": "Outbound email test",
        "info": "",
        "x": 250,
        "y": 180,
        "wires": []
    }
]

Can you check a) that you actually have an ipv4 address and b) that you can ping smtp.ionos.co.uk and c) that is responds via ipv4.

1 Like

Yes it appears to have. Results of ifconfig

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.60.20 netmask 255.255.255.0 broadcast 192.168.60.255
inet6 fe80::6464:6826:8aca:8eeb prefixlen 64 scopeid 0x20
ether dc:a6:32:79:53:40 txqueuelen 1000 (Ethernet)
RX packets 136476 bytes 13123578 (12.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 172858 bytes 40989886 (39.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Ping shows about 18ms latency.
Yes IP V4 addresses are being used.

Which OS are you using and which version of nodejs ?

(It seems that in Node17 / 18 - they have changed the default reporting order from dns to prioritise ipv6)

PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

try typing node -v at a command prompt.

1 Like

node -v

v14.19.3

hmm - most odd.

1 Like

Yes.
I've been trying all of the 'fat finger' errors I can think off. No luck.
The network appears to be working.
The RPi is communicating with other devices.
The test flow worked previously.

I guess you could try turning off ipv6 in the Pi network manager. (may need a reboot)

1 Like

Removed IPv6. Same error.

$ sudo nano /etc/sysctl .conf

Add this to the end:

net.ipv6.conf.all.disable_ipv6=1

net.ipv6.conf.default.disable_ipv6=1

net.ipv6.conf.lo.disable_ipv6=1

net.ipv6.conf.eth0.disable_ipv6 = 1

rebooted

ifconfig now shows:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.60.20 netmask 255.255.255.0 broadcast 192.168.60.255
ether dc:a6:32:79:53:40 txqueuelen 1000 (Ethernet)
RX packets 20418 bytes 2811277 (2.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 25720 bytes 9399504 (8.9 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Brute force solution:

Delete email nodes.
Un install node-red-node-email
Re install
Now works.

1 Like

Ahhhh ... It's back !

Seems that there is a bug / problem of some sort here.
Any suggestions for using an alternate emailer?

Check you have a functional default route ip -4 r

Hello,
This seems to be OK.

pi@NR1:~/.node-red $ ip -4 r
default via 192.168.60.1 dev eth0 proto dhcp src 192.168.60.20 metric 202
192.168.60.0/24 dev eth0 proto dhcp scope link src 192.168.60.20 metric 202

pi@NR1:~/.node-red $ ping 192.168.60.1
PING 192.168.60.1 (192.168.60.1) 56(84) bytes of data.
64 bytes from 192.168.60.1: icmp_seq=1 ttl=255 time=0.250 ms

.

I have figured out a work around, although not a very elegant one.

Having installed the Nodejs module nodemailer upon which the Node-red-node-email node is based. The same error is returned.
However, if nodemailer is configured to connect to the smtp server using an IP address, it works.

.

For other's who may be interested, in outline the steps are:

Install nodemailer:
1: cd /home/pi/.node-red
2: npm install nodemailer

[This next step may be optional]
3: sudo reboot

4: Create a new function within Node-Red
5: In the Setup tab, add a new Module, with Module name: nodemailer Import as: nodemailer

6: The nodemailer.createTransport call needs to look something like this:

  // create reusable transporter object using the default SMTP transport
  let transporter = nodemailer.createTransport({

    host: "123.765.23.98",   // IP address of the target smtp server
    port: 465,                       // port at IP address offering smtp service
    secure:  true, // true for 465, false for other ports
    tls: {
        // must provide server name, otherwise TLS certificate check will fail
        // Use reverse IP look up to find exact URL on the SSL certificate
        servername: "example.com"
}
    auth: {
      user: "myemail@smtpserver.com",    // username
      pass: "my_secret",   // password
    },
  });

The problem appears to be located somewhere in, or below nodemailer.