guileen / node-sendmail

send mail without setting up a SMTP server
http://guileen.github.com/node-sendmail
MIT License
559 stars 110 forks source link

Error: can not connect to any SMTP server #56

Closed osher closed 5 years ago

osher commented 5 years ago

Error: can not connect to any SMTP server

Expected Behavior

Mail to be sent and a confirmation message to be print

Current Behavior

error on connectMx Error: can not connect to any SMTP server
    at tryConnect (C:\ws\opensource\sandbox\node_modules\sendmail\sendmail.js:88:49)
    at Socket.<anonymous> (C:\ws\opensource\sandbox\node_modules\sendmail\sendmail.js:94:13)
    at Socket.emit (events.js:182:13)
    at Socket.EventEmitter.emit (domain.js:442:20)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Possible Solution

I don't know... Check the reproduction scenario - What am I doing wrong? Got any tip for me?

Steps to Reproduce (for bugs)

$ node -v
v10.11.0

$ npm i sendmail
npm WARN deprecated mailcomposer@3.12.0: This project is unmaintained
npm WARN deprecated buildmail@3.10.0: This project is unmaintained
npm WARN node-lts-notifier@1.0.0 No description
npm WARN node-lts-notifier@1.0.0 No repository field.

+ sendmail@1.4.1
updated 1 package and audited 30 packages in 9.45s
found 0 vulnerabilities

$ node
> require('sendmail')()({to: 'secretsecret+secret@gmail.com', from: 'secretsecret+noreply@gmail.com', subject: 'wdf..', html: '<h1>boo</h1>'}, console.log);1
1
> mx resolved:  [ { exchange: 'alt4.gmail-smtp-in.l.google.com', priority: 40 },
  { exchange: 'alt3.gmail-smtp-in.l.google.com', priority: 30 },
  { exchange: 'alt2.gmail-smtp-in.l.google.com', priority: 20 },
  { exchange: 'alt1.gmail-smtp-in.l.google.com', priority: 10 },
  { exchange: 'gmail-smtp-in.l.google.com', priority: 5 } ]
Error on connectMx for:  { exchange: 'alt4.gmail-smtp-in.l.google.com', priority: 40 } { Error: connect ETIMEDOUT 209.85.202.26:25
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '209.85.202.26',
  port: 25 }
Error on connectMx for:  { exchange: 'alt3.gmail-smtp-in.l.google.com', priority: 30 } { Error: connect ETIMEDOUT 64.233.186.27:25
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '64.233.186.27',
  port: 25 }
Error on connectMx for:  { exchange: 'alt2.gmail-smtp-in.l.google.com', priority: 20 } { Error: connect ETIMEDOUT 74.125.141.26:25
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '74.125.141.26',
  port: 25 }
Error on connectMx for:  { exchange: 'alt1.gmail-smtp-in.l.google.com', priority: 10 } { Error: connect ETIMEDOUT 209.85.144.26:25
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '209.85.144.26',
  port: 25 }
Error on connectMx for:  { exchange: 'gmail-smtp-in.l.google.com', priority: 5 } { Error: connect ETIMEDOUT 74.125.129.26:25
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '74.125.129.26',
  port: 25 }
error on connectMx Error: can not connect to any SMTP server
    at tryConnect (C:\ws\opensource\sandbox\node_modules\sendmail\sendmail.js:88:49)
    at Socket.<anonymous> (C:\ws\opensource\sandbox\node_modules\sendmail\sendmail.js:94:13)
    at Socket.emit (events.js:182:13)
    at Socket.EventEmitter.emit (domain.js:442:20)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Context

I'm trying to create a job one can run as cron task on some headless machine with node, the job should sample an RSS feed and send a mail to a configured target if one of the top 10 messages in the feed fit to a given criteria.

Your Environment

GreenPioneer commented 5 years ago

@osher have you been able to get it to work with any email besides gmail?

osher commented 5 years ago

yes - the problem is that the host I was using for development was not listed in the mx record.

I think you should state this more clearly for users who don't know how mail and the war on spam work and how mail servers validate each other.

Thanks for the follow up.