SMTP commect() failed

How to get rid of “SMTP connect() failed” error.


Facing an error that says “SMTP connect () failed”?

There are different reasons that cause this error. But before discussing errors we should have knowledge of SMTP. The SMTP is a Simple Mail Transfer Protocol. it is an internet standard communication protocol for electronic mail transmission. Mail servers and message transfer agents use SMTP.

Here are SMTP connect () failure error and its solution:

1:Problem with The Latest Version Of PHP

This problem is in the latest version of PHP.it occurred because PHP has implemented stricter SSL behavior

Here is a help doc on PHPMailer wiki which has a section around this.


Here is solution of this problem:

$mail->SMTPOptions = array(

‘ssl’ => array(

‘verify_peer’ => false,

‘verify_peer_name’ => false,

‘allow_self_signed’ => true



2: Using Go daddy As The Hosting Provider

If you are using third-party SMTP. Then you will face this error

Mailer Error: SMTP connect() failed.

This error is because of the silly rule that Go daddy has imposed. Go daddy blocked the outgoing SMTP because they want that their user will use their SMTP instead of outgoing SMTP


#1- Use Godaddy SMTP Instead Of outsource SMTP:

#2- Use Email APIs Instead Of Any SMTP:

Go daddy blocked outsource SMTP but didn’t block HTTP ports. So you can use APIs instead of third party SMTP

3: Getting SMTP Connection Failure On A Shared Hosting Provider

If you are using a shared hosting provider and using outsource SMTP then you can face this error:

SMTP connect () failed

This error is because of the Firewall rule that strict third-party SMTP. This rule is imposed to avoid users from sending spam.


1.Use Email APIs instead of any SMTP

2. Use out Ports

 Out Ports could be an excellent ASCII text file on GitHub that scans all of your ports and provides the result. Once out Ports is put in, you’ll be able to sort the subsequent command within the terminal to envision port twenty-five connectivity: out Ports twenty-five

4: SELinux Blocking Issue

If you are facing an error like:

SMTP -> ERROR: Failed to connect to server: Permission denied (13)

Then this error is due to SELinux. This is the problem that is found in many Linux machines such as Centos etc. In this error, SELinux is preventing the webserver or PHP from sending mails.


Use getsebool Command

getsebool httpd_can_sendmail

getsebool httpd_can_network_connect

It will display message if getsebool is disabled

getsebool: SELinux is disabled

To turn on getsebool,use command:

sudo setsebool -P httpd_can_sendmail 1

sudo setsebool -P httpd_can_network_connect 1

5: PHPMailer SMTP Connection Failed Because Of SSL Support Issue with PHP

If you face this error then it could be due to SSL.your open SSL extension might not be enabled in the php.ini file.to confirm whether it is the reason, type the following command:

$mail->SMTPDebug = 2;

By setting the worth of SMTPDebug property to two, you’ll be truly obtaining each server and consumer level transcripts


Use the following command to enable SSL extension


And enable it in the PHP.INI file

6: PHPMailer Unable To Connect To SMTP Because Of the IPv6 Blocking Issue

Some hosting companies provide IPv6 connections but restrict SMTP on IPv6 and enabled it in IPv4.


Use the following command to set host property to IPv4

$mail->Host = gethostbyname(‘smtp.pepipost.com’);

7: Getting the Error “Could Not Instantiate Mail Function”

This Error occurs when PHP installation is not correctly configured to call the main function


Check the sendmail_path in your php.ini file.

Leave a Reply

Your email address will not be published.

Previous Post

Things You Need To Know About VIMS Pinnacle Today.

Next Post
Slay the spire twitch integration

Learn tactics of Slay The Spire Twitch Integration

Related Posts