Hi,

Last week, PHPMailer suddenly stopped working. I got the following as the error message when I send the test e-mail:

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

I've found the same issue with the module SMTP Authentication Support.

Any idea what could have caused this? Any good suggestions for debugging this?

Comments

smk-ka’s picture

Connection time-out means the mail server cannot be reached anymore. If the mail server is different from your web server (i.e. not localhost) I'd check with your hosting provider whether they enabled some sort of firewall that blocks connections on the SMTP port (port 25 usually).

Relia’s picture

Hello I have the same problem.

I set up PHPMailer to send mails trought gmail:

Primary SMTP server:mail.gbt.tfo.upm.es
SMTP Port: 465
Use secure protocol: SSL

User: usergmail@gmail.com
password: gmailpassword

TEst configuration: mailtutest@domain.com

But when I submit clickin save configuration, the next error message appear:

A test e-mail has been sent to fjpeces@gfgf.es. You may want to check the logs for any error messages.
SMTP -> ERROR: Failed to connect to server: Connection timed out (110)
SMTP Error: Could not connect to SMTP host.

I'm using OpenSuSe 10.3, Server Apache2, php 5.2.5.

I think the problem is the ports are closed to outside, but before to communicate with the admin, i'd want read your opinions!

thanks!

LEternity’s picture

I contacted my provider and they fixed the problem. I.e. they screwed up...

Relia’s picture

i fixed the problem, I cotacted admin and the problem was the ports! They are closed!

smk-ka’s picture

Category:bug» support
Status:Active» Fixed
Issue tags:-SMTP Authentication, -phpmailer, -smtp

Thanks for your feedback, I've added a description for this error to README.txt, based on what I said in #1.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

satheeshkumar.six’s picture

In localhost SMTP work's fine, but , site it does not work SMTP.
I give same configuration in SMTP localhost and site.

but I get below error

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

I changed port number and name....etc..
but i get same error....
how can I slove this?

Thanks in advance..

smk-ka’s picture

@satheeshkumarr Read comment #1. Contact your hosting provider to open specific firewall ports.

Mahadirz’s picture

Version:6.x-2.1» 7.x-3.x-dev
Component:Code» Miscellaneous
Status:Closed (fixed)» Active

I also got this same problem before...
Try checking all your files and directories permission. If all your files and folder permission is set to 777 they can't access to SMTP config.

So reset the permission of all the files to 644 while the folders to 755 .

cheers...
http://www.mahadirlab.com/en

zabalex’s picture

I had the same issue with my host. They told me to try every possible option, stated that it was a problem with my code, email server, application (drupal), etc.
I wasted 2 weeks, than hired a guy to develop firewall ports blocking detection application, and here it is. As soon as I was able to proove to hosting company that they blocked port 465, they did not admin problem. As soon as I showed them this tool, yes, they admitted that they have problem and opened the port.
Here is the tool: Port forwarding tester external server:

Let me know what you think

earth1’s picture

@smk-ka #1. I am using PHPMailer 6.x-2.2. Firewall is not the answer.

error -> SMTP error: could not connect to SMTP host.

The website is using godaddy with jangosmtp as it email system. It's Primary SMTP server: relay.jangostmp.net and SMTP port: 587. The godaddy representative said go to my MX (Mail Exchanger) and set relay.jangostmp.net. But this didn't work. I am running out of ideas. Can you help me?

Thanks in advance

zabalex’s picture

I spent so much time on issues like that, I might be able to help you Earth1 if the tool from my previous post doesn't show port as blocked.
Don't trust their advise on MX Exchanger. I prooved back to GoDaddy that over 50% of popular organizations don't set their relays, and their emails still go through fine.
What is your domain? Send me PM if you don't want to list it here.

keithm’s picture

This problem may be a result of enabling IPv6 support in the operating system. I saw several sites with working PHPMailer configurations break when my host enabled IPv6. PHP has multiple known bugs in dealing with IPv6.

PHPMailer uses the PHP fsockopen() function that has this known bug.

The problem is that fsockopen() doesn't detect that a connection was actively refused and instead times out on it.

The problem scenario occurs when the host has both ipv4 and ipv6 addresses (e.g,, smtp.gmail.com), the service is only listening on ipv4 but ipv6 has precedence, which results in:

  1. trying IPv6
  2. time out
  3. fail

instead of:

  1. trying IPv6
  2. connection refused
  3. trying IPv4
  4. success

If this is the problem, you can work around it by setting the IP address directly in the PHPMailer settings or in /etc/hosts. The problem still exists (at least) in PHP v5.3.2.

vvenk’s picture

Hi:

I am on a Windows 7 machine and developing an application that has SendEmail as a function using VB.Net and MS Visual Studio 2010.

The code works fine on another Windows 7 machine. The only difference is that the laptop it does not work is a corporate laptop and I am part of the Administrators group on that laptop.

I used the tool and it says the port is open.

Any idea how to resolve the issue?

venki

ravi_dev’s picture

I have another mail server for my site then how can i connect '@fsockopen("www.google.com", 80, $errno, $errstr, 10)'?