Drupal SMTP error "could not connect to smtp host" - Fix it Now ?

Drupal SMTP error "could not connect to smtp host" - Fix it Now ?

Drupal users sometimes get the SMTP error "could not connect to smtp host" while sending mails from the site.

This error can happen when there is a firewall issue or as a result of incorrect SMTP details.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to resolve related Drupal errors.

In this context, we shall look into methods to fix Drupal SMTP error "could not connect to smtp host".

Nature of Drupal SMTP error "could not connect to smtp host" 

We sometimes receive requests complaining that they are receiving the following error while sending emails from Drupal:

phpmailerException: SMTP Error: Could not connect to SMTP host

The Main reasons for this error includes:

1. Firewall restrictions.

2. Email settings at the provider end.

3. SMTP auth support settings.

How to fix Drupal SMTP error "could not connect to smtp host" ?

One of the first step to follow when we see the "could not connect to smtp host" error in Drupal is to enable the SMTP debug available on the SMTP configuration page.

When we try to send mails with this option enabled, it gives us a more detailed story of why we can't send the message.

1. SMTP auth support settings

As discussed earlier, a common reason for the error is the wrong SMTP settings. We recently fixed this error where the issue was that the port settings were entered incorrectly.

So, it was clear that PHPMailer was unable to contact the SMTP server defined in the mail server settings.

Similarly, another customer reported that his emails did not work after configuring the SMTP module in Drupal.

Therefore, we checked the SMTP server settings in Drupal. Then, they found that the wrong SMTP server name setting caused the problem with emails.

So, we solved the issue by providing the correct SMTP server name and port settings in Drupal SMTP server settings.

2. Email settings at the provider end

At times, this error could be related to restrictions at the email provider end. Often, users find that GMail blocked them from sending mails. 

In this case, try moving to a dedicated SMTP transaction email server.

Sometimes users receive errors while using 25 ports for connection.

Switching to 465  worked in such cases.

Often, users also require to enable "less secure apps" on the gmail/google apps account. Also, they have to set up the smtp relay in the google apps admin console from the Advanced Settings option.

3. Firewall restriction

Our Support Experts have noticed cases where the SMTP ports are blocked at the server firewall end. Thus we need to allow access for firewall or network to send mail for Linux, windows and mac.

Following command set permission for Linux to allow ports 465 and 587.

i.  iptables -I OUTPUT -p tcp –dport 465 -j ACCEPT

ii. iptables -I OUTPUT -p tcp –dport 587 -j ACCEPT

[Need urgent assistance in fixing Drupal SMTP errors ? We can help you. ]

Who We Are ?

Most prominent, efficient, and well-performing IT companies and software solutions.

Related Posts