question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: " can not connect to any SMTP server"

See original GitHub issue

Expected Behavior

Using your package to send mails, the server was unable to send anything. Here’s the server code I used:

var sendmail         = require('sendmail')({
  logger: {
    debug: console.log,
    info: console.info,
    warn: console.warn,
    error: console.error
  },
    silent: false
})

sendmail({
  from: 'no-reply@yourdomain.com',
  to: 'thomas@lucidweb.io',
  subject: 'test sendmail',
  html: 'Mail of test sendmail ',
}, function(err, reply) {
  console.log(err && err.stack);
  console.dir(reply);
});

And here’s the console error I got:

mx resolved:  [ { exchange: 'alt3.aspmx.l.google.com', priority: 10 },
  { exchange: 'alt4.aspmx.l.google.com', priority: 10 },
  { exchange: 'alt1.aspmx.l.google.com', priority: 5 },
  { exchange: 'alt2.aspmx.l.google.com', priority: 5 },
  { exchange: 'aspmx.l.google.com', priority: 1 } ]
Error on connectMx for:  { exchange: 'alt3.aspmx.l.google.com', priority: 10 } { [Error: connect ETIMEDOUT 74.125.23.27:25]
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '74.125.23.27',
  port: 25 }
Error on connectMx for:  { exchange: 'alt4.aspmx.l.google.com', priority: 10 } { [Error: connect ETIMEDOUT 173.194.72.27:25]
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '173.194.72.27',
  port: 25 }
Error on connectMx for:  { exchange: 'alt1.aspmx.l.google.com', priority: 5 } { [Error: connect ETIMEDOUT 173.194.73.27:25]
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '173.194.73.27',
  port: 25 }
Error on connectMx for:  { exchange: 'alt2.aspmx.l.google.com', priority: 5 } { [Error: connect ETIMEDOUT 74.125.200.27:25]
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '74.125.200.27',
  port: 25 }
Error on connectMx for:  { exchange: 'aspmx.l.google.com', priority: 1 } { [Error: connect ETIMEDOUT 74.125.195.27:25]
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '74.125.195.27',
  port: 25 }
error on connectMx Error: can not connect to any SMTP server
    at tryConnect (D:\My Files\work\www\lucidweb\node_modules\sendmail\sendmail.js:78:49)
    at Socket.<anonymous> (D:\My Files\work\www\lucidweb\node_modules\sendmail\sendmail.js:84:15)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at emitErrorNT (net.js:1253:8)
    at nextTickCallbackWith2Args (node.js:442:9)
    at process._tickCallback (node.js:356:17)
Error: can not connect to any SMTP server
    at tryConnect (D:\My Files\work\www\lucidweb\node_modules\sendmail\sendmail.js:78:49)
    at Socket.<anonymous> (D:\My Files\work\www\lucidweb\node_modules\sendmail\sendmail.js:84:15)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at emitErrorNT (net.js:1253:8)
    at nextTickCallbackWith2Args (node.js:442:9)
    at process._tickCallback (node.js:356:17)
undefined

Context

I’m trying to send a mail with informations received from a form

Your Environment

Windows 10 NodeJS v4.4.3

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
CherryNerdcommented, Sep 27, 2016

I’ve had the same sort of problem, but it was resolved the moment I send a mail from the domain the app was installed on. E.g. I have a Digital Ocean droplet with the domain geex.company on it and mails are sent without any problem, but the moment I try to send a mail from a domain that is not pointed by DNS to that VPS, like “outlook.com”, it gets blocked by gmail servers and other services list it as “spam”.

0reactions
sebringjcommented, Mar 11, 2018

I am using node mailer with SendGrid

    "nodemailer": "^2.7.0",
    "nodemailer-smtp-transport": "^2.7.2",

I was stuck not being able to send out to port 25 locally. SendGrid allows port 2525 so I tried that and worked! Apparently, my ISP does not block port 2525 so I can do local development easily.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable Send Email due to errors 'Cannot connect to SMTP ...
The 4.4.1 SMTP Status appears when no answer is received from the host or when the connection is lost. This could be due...
Read more >
"Smtp error: Failed to connect to server" - Causes and Fixes
1. SMTP restrictions on the server. Servers restrict the programs that can directly connect to remote servers and send mail. · 2. Firewall ......
Read more >
How to solve the “SMTP Error: Failed to connect to server” Error?
1. SMTP restrictions on the server. Servers impose restrictions on the programs that can connect directly with remote servers and send an email....
Read more >
[Solution] SMTP error: failed to connect to server - Courier
Solution - Here's How To Resolve It · Ensure that the email server does not have any restrictions that may prevent a client...
Read more >
Cannot send emails: How to fix email sending issues
Check your internet connection. Yup. · Check your SMTP server details. · Verify all usernames and passwords. · Check your SMTP server connection....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found