Smtp error failed to connect to server no route to host 113

Normally, 'SMTP error no route to host' error occurs while sending emails. this error occurs when the port is blocked at the hosting end or ISP.

Normally, ‘SMTP error no route to host’ error occurs while sending emails.

Usually, this error occurs when the port is blocked at the hosting end or ISP.

Here at Bobcares, we have seen several such SMTP related errors as part of our Server Management Services for web hosts and online service providers.

Today we’ll take a look at how to fix this SMTP error.

Causes for SMTP error no route to host

While trying to send mail, it results in the error:

SMTP ERROR: Failed to connect to server: No route to host (65)

Now, let’s see the different causes of this error.

  • Firstly, port 25 blocked in the server firewwall which can be caused by a iptables reject with one of the type icmp-net-unreachable or icmp-host-unreachable.
-j REJECT –reject-with icmp-host-unreachable

The following reject types are currently valid:

icmp-net-unreachable
icmp-host-unreachable
icmp-port-unreachable
icmp-proto-unreachable
icmp-net-prohibited
icmp-host-prohibited.

The default error message is to send a port-unreachable to the host.

To see iptables rules, run the following command.

sudo iptables -S
  • Secondly, port blocked at the hosting side or ISP

This can be tested using the command given below:

telnet server_name port_number

For instance,

telnet mail.bobcares.com 25
  • Host is offline/service is not running

We can check whether the host is online using ping command.

ping server_ip

The service itself might not have been started. We can check to see if the service has been started and is running properly using the following command:

sudo systemctl status SERVICENAME
  • Using an incorrect port
  • DNS Is Improperly Configured

We should try to ping the IP address that we are looking to connect to. It could be that the computer is not connecting to a DNS server properly.

ping -c3 your.server.ip

If the ping works but connecting a domain name doesn’t, we are looking at a DNS issue.

  • Finally, incorrect Network or Host Configuration

Solution for SMTP error no route to host

  •  Firstly, open the port in the server firewall.
  •  Next, contact hosting support or ISP and ask them to remove the block.
  •  Then, use a different port like 587.
  •  DNS is improperly configured

Systemd users can run systemd-resolve –status to check the DNS servers that our system is using.

In most cases, our computer will discover the relevant DNS information over DHCP. If we are using a static IP or something on our network is configured differently, we may have to set our DNS manually.

Open “/etc/resolv.conf.”

In that file, uncomment the DNS line and add either the IP of our router or another known DNS server.

  •  Incorrect Network or Host Configuration

First, make sure that our computer’s network configuration is correct. Double-check the configuration files themselves and see if we can connect to the Internet another way.

If we are using a specific hostname to connect or we have set up specific hosts on either the server or the client, we need to make sure both machines can connect to each other. Check the configurations of “/etc/hosts,” “/etc/hosts.allow” and “/etc/hosts.deny”.

[Still, not able to resolve this SMTP error? We can help you in fixing it]

Conclusion

In short, this error occurs when the port is blocked at the hosting end or ISP. Today, we saw how our Support Engineers resolve this error.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = «owonCMyG5nEQ0aD71QM»;

Ok So I’m trying to update old code to use SMTP authentication through our GMail hosted company email. I’m running into the following error:


SMTP -> ERROR: Failed to connect to server: No route to host (113)
SMTP Error: Could not connect to SMTP host.
My code is (note some things sanitized for public viewing):

<?php
   $paths = get_include_path();
   set_include_path($paths . PATH_SEPARATOR . dirname(__FILE__) . '/phpmailer');
   include_once('class.phpmailer.php');
   $mail = new phpmailer;
      
   // Constant email settings.
   $mail->IsSMTP();
   $mail->SMTPAuth   = TRUE;
   $mail->SMTPSecure = "tls";
   $mail->Host       = "smtp.gmail.com";
   $mail->Port       = 587;
   $mail->Username   = "--@noas.com";
   $mail->Password   = "--";
   $mail->From       = "contact@noas.com";
   $mail->FromName   = "NOAS Contact";
   $mail->WordWrap   = 75;
   $mail->Subject    = "10th Anniversary Dave Thomas Celebrity Cookoff - Chef Invite";
   $mail->AddReplyTo("--@noas.com", "--");
   $mail->IsHTML(true);
   $mail->addBcc('--@noas.com','--');
      
      $mail->SMTPDebug = 2; // For debugging, change to 0 when working
      
   foreach( $emails as $info ) {
      $mail->AddAddress($info['email'], $info['name']);
      $mail->msgHTML(buildmsg($info['name']));
      
      // Send mail message to each recipient
      if( $mail->Send() )
         $content .= 'Message to '. $info['name'] .' sent successfully.<br />';
      else
         $content .= 'Message to '. $info['name'] .' failed to send.<br />';
      
      $mail->clearAddresses();
   }
?>

Open in new window

I’ve also tried changing to this as in a document included:

<?php
   $mail->SMTPSecure = "tls";
   $mail->Host       = "smtp.gmail.com";
   $mail->Port       = 587;

Open in new window

I was using http://phpmailer.worxware.com/index….=examplebgmail plus the documents included in the ZIP to set up the settings, So I don’t see what’s wrong. Sometimes I get this error instead:

SMTP -> ERROR: Failed to connect to server: Connection timed out (110)
SMTP Error: Could not connect to SMTP host.

Either way its not sending emails, Any help would be greatly appreciated =D

У меня продолжающаяся проблема SMTP с PHPMailer, описанная здесь: https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#php-56-certificate-verification-failure

Я просмотрел приведенные ошибки, и, насколько я могу судить, это главный виновник

Предупреждение: stream_socket_enable_crypto (): сертификат узла CN = *.mywebhost.com' did not match expected CN= mail.mydomain.com ‘в /path/to/phpmailer/class.smtp.php в строке 355

Другие идеи / информация.

  1. У меня установлен SSL, и я проверил его законность здесь: https://www.digicert.com / help /
  2. Это среда виртуального хостинга.
  3. Это среда PHP 7.
  4. Это настройка поддомена. Итак, SSL предназначен для sub.mydomain.com , а $mail->Host — для mail.mydomain.com . Не знаю, актуально это или нет, но так оно и есть.

Я уже изучил документацию PHPMailer и понятия не имею, почему это все еще происходит. Действующий SSL, без SMTP ….. Есть идеи, где я могу это исправить?

1 ответ

Лучший ответ

Предположительно у вас есть такой набор:

$mail->Host = 'mail.mydomain.com';

Но когда вы подключаетесь к нему, он фактически подключается к почтовому узлу вашего интернет-провайдера (вероятно, что-то вроде mail.mywebhost.com, который представляет сертификат *.mywebhost.com), и, конечно же, имя в сертификате сервера, которое у вас есть не соответствует. Правильным решением этой проблемы является изменение вашего свойства Host на использование настоящего имени почтового сервера, так как тогда сертификат будет соответствовать, и у вас не будет ошибок несоответствия:

$mail->Host = 'mail.mywebhost.com';

(вам нужно узнать, какое точное имя должно быть). Чтобы это работало с вашим собственным сертификатом, вам нужно будет запустить собственный почтовый сервер на его собственном IP-адресе, чего вы вряд ли получите на виртуальном хостинге.

Альтернативный обходной путь, также описанный в руководстве по устранению неполадок, — отключить проверку сертификата (как это было в PHP до версии 5.6), но вы не должны этого делать. Вы знаете, почему это не удается, поэтому вам следует исправить это должным образом, а не просто подавить ошибку.


3

Synchro
3 Окт 2017 в 18:32

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Smtp error failed to connect to server connection timed out 110 phpmailer
  • Smtp error failed to connect to server connection refused 111 smtp connect failed
  • Smtp error data not accepted что значит
  • Smtp error data not accepted smtp server error data end command failed detail
  • Smtp error could not connect to smtp host что это

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии