How to fix “SMTP Error: Could not connect to SMTP host.”

Emails play a crucial role in online businesses. It can be bothersome when emails stop working. You may lose an urgent invite or important notification.

As part of our Dedicated Support Services, we help website owners configure email services for their businesses and assist server owners to fix email errors.

One such commonly encountered error is “SMTP Error: Could not connect to SMTP host.” Today we’ll see what causes that error and how we fix it.

“Unable to connect to SMTP host.” – When do you see this error?

Majority of the SMB websites run on CMS such as WordPress, Joomla, WHMCS, etc. Most of these CMS software are configured to send emails from them.

These emails can be sent for various purposes – such as order confirmations, invoice delivery, contact form submissions, password resets, account registration and so on.

But due to any issues related to email server or configuration, this mail delivery can fail and give out the error “SMTP Error: Could not connect to SMTP host.”

The same error can present in different forms, such as:

SMTP -> ERROR: Failed to connect to server: (0)

SMTP Error: Could not connect to SMTP host. Message could not be sent.

Mailer Error: SMTP Error: Could not connect to SMTP host.

‘SMTP connect() failed’

What causes the email error “Unable to connect to SMTP host”

A number of reasons can lead to the SMTP connection error. That’s what often perplex the website owners when they see this error.

Here are the main causes we’ve identified in our debugging process.

1. Security restrictions

Exim servers, by default, have some security restrictions to avoid outbound spamming and to protect server IP reputation from blacklists. These restrictions lead to SMTP errors.

The setting in WHM ‘Server Configuration > Tweak Settings > Mail => ‘Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak)’, blocks outgoing SMTP from website software.

Exim security restrictions

 

Another setting in WHM that provides the same restriction is, “WHM Home » Security Center » SMTP Restrictions”. This prevents users from bypassing the mail server to send mail.

WHM – SMTP restriction

 

To further secure mail servers, most servers have firewalls such as CSF, configured in them. Firewall rules can be configured to selectively or fully block connectivity to the SMTP ports.

Many ISPs also block the default SMTP port (25), to avoid spamming attempts. SELinux restriction is another security feature that can cause connection issues to mail server.

Website owners who use gmail as their SMTP server would face further security restrictions imposed by Google. By default, gmail does not allow connections from third party software.

If the option “access for less secure apps” is not enabled in the gmail account, users get the error “Unable to connect to SMTP host” in their websites.

2. Mail server configuration

The SMTP server is often specified as a hostname in the mail settings of the software. A DNS failure or temporary issues can affect the name resolution of the mail server.

In such scenarios, the mailing software will not be able to contact the SMTP server, causing connection errors. If the mail server has another service running on the SMTP port configured, the same issue occurs.

Another issue related to mail server is the lack of support for encryption. If the OpenSSL module is not configured properly or if the PHP extension is not working fine, it will throw errors during SMTP connections.

3. Client side mail settings

To send mails from website software, you need to configure the settings such as SMTP host, port and mail account username and password.

Any configuration mistakes in these settings can cause email errors due to authentication failures and show the message “Unable to connect to SMTP host”.

If the connection is attempted to a different mail server, it will not work. This can happen especially in the cases of website migration from one server to another.

Also, when encryption is not chosen for mail settings, many mail servers can reject the connection attempt and show “Unable to connect to SMTP host” error.

4. Software errors

Many website owners customize their software with plugins that enable them to send mails. Many others have custom code and tweaks done in their CMS.

Due to software updates, feature modifications, plugin issue or other code related bugs, the SMTP authentication support can stop working, giving out SMTP errors in the site.

How we fix the email error “Unable to connect to SMTP host”

To fix the error, we first figure out the cause for it. We examine the software settings, test the connectivity to mail server, and other security restrictions in the server to pinpoint the issue.

Once the cause for the error is identified, we make appropriate fixes such as re-configuring firewall rules and tweaking the security settings, so that mail delivery works fine.

For software updates and installs, we take proper backups and conduct mock installs beforehand, which help us to perform upgrades and fixes in websites without causing any errors.

Conclusion

Email errors are the most commonly encountered issues in servers. Today we saw why “Unable to connect to SMTP host” error happens in websites and how our Dedicated Hosting Engineers fix them.

 


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.

SEE SERVER ADMIN PLANS

Submit a Comment

Your email address will not be published. Required fields are marked *

Bobcares
Bobcares is a server management company that helps businesses deliver uninterrupted and secure online services. Our engineers manage close to 51,500 servers that include virtualized servers, cloud infrastructure, physical server clusters, and more.
MORE ABOUT BOBCARES