0

Last week nodemailer stopped working on a number of scripts I run as scheduled tasks on a windows 10 pc. After updating nodejs and nodemailer, switching off the firewall, and trying on another pc, I still cannot get nodemailer to send emails. I have contacted my email provider who assures me nothing has changed at their end?? I can send and receive emails using Mozilla Thunderbird. Using nodemailer debug I have got the following log.

The way I read it is my email provider is no longer accepting 127.0.0.1 as an ip address from nodemailer. Is this correct and is there anyway to change the ip address? Or is there another work around?



    [2022-06-20 00:23:25] DEBUG Creating transport: nodemailer (6.7.5; +https://nodemailer.com/; SMTP/6.7.5[client:6.7.5])
    [2022-06-20 00:23:25] DEBUG Sending mail using SMTP/6.7.5[client:6.7.5]
    [2022-06-20 00:23:26] DEBUG [VIUENUHea4] Resolved mailx.freeparking.co.nz as 43.245.52.240 [cache miss]
    [2022-06-20 00:23:26] INFO  [VIUENUHea4] Secure connection established to 43.245.52.240:465
    [2022-06-20 00:23:29] DEBUG [VIUENUHea4] S: 220 mailx.hosts.net.nz - ESMTP - jessie - Mon, 20 Jun 2022 12:23:29 +1200
    [2022-06-20 00:23:29] DEBUG [VIUENUHea4] C: EHLO [127.0.0.1]
    [2022-06-20 00:23:29] DEBUG [VIUENUHea4] S: 550-#h1 - An IP of 127.0.0.1 as a HELO is not currently accepted due to high
    [2022-06-20 00:23:29] DEBUG [VIUENUHea4] S: 550 volumes of bot activity
    [2022-06-20 00:23:29] DEBUG [VIUENUHea4] C: HELO [127.0.0.1]
    [2022-06-20 00:23:29] INFO  [VIUENUHea4] Connection closed
    [2022-06-20 00:23:29] ERROR [VIUENUHea4] Connection closed unexpectedly
    [2022-06-20 00:23:29] DEBUG [VIUENUHea4] Closing connection to the server using "end"
    [2022-06-20 00:23:29] ERROR Send Error: Connection closed unexpectedly

Apoorva Chikara
  • 8,277
  • 3
  • 20
  • 35
Kevin
  • 229
  • 1
  • 4
  • 12

2 Answers2

0

I searched 127.0.0.1 in the nodemailer files and found it in the
"node_modules\nodemailer\lib\smtp-connection\index.js" file. I changed
"defaultHostname = '[127.0.0.1]';" to
"defaultHostname = '[135.0.0.1]';" (random ip) and it now works.
There may be a better solution, please update if there is.

Kevin
  • 229
  • 1
  • 4
  • 12
0

I was battling this same issue, but I resolved it this way

I changed "secure" to "secureConnection" and it worked perfectly well

Before: [1]: https://i.stack.imgur.com/qpQt9.png
Error message: https://i.stack.imgur.com/M1oHB.png

After: [2]: https://i.stack.imgur.com/WZSea.png

PS: I'm loading all the options from config object called "mail"

I hope this helps. Thanks

  • Thank you for your answer, unfortunately in my case this does not work. I still have to change the defaultHostname in the index file. – Kevin Jun 22 '22 at 21:00