How to fix email error ‘SMTP connect() failed’ in WordPress sites
WordPress is the most widely used CMS for websites. Sending out mails from WordPress is required in scenarios such as contact form submissions or password resets.
‘SMTP connect() failed‘ is a commonly encountered error in WordPress, due to which emails fail to be send from your WordPress site.
Configuring email settings in WordPress
By Default, WordPress uses the PHP Mail function to send emails. But using PHP mail function is a less secure method and makes the server vulnerable to spamming.
As a result, many webservers have PHP mail() function disabled for security purposes. In those servers, mails can be send from WordPress using SMTP.
SMTP uses proper authentication and is therefore more secure. There are WordPress plugins such as ‘WP Mail SMTP‘, that has to be configured to send mails via SMTP.
Once the SMTP plugin is activated, a new ‘Email‘ menu will show up under the Settings in WP. You can configure the email delivery settings in that option.
You can give your email address, password, mail server name and port in the Email settings and save it. You can test the mail delivery to see if the settings are fine.
The following settings can be configured in the Email settings:
From Email - the email address you want to send emails from From Name - the name that your emails will be received from Mailer - you can choose between the default PHP Mail function and SMTP SMTP Host - the hostname for your SMTP server SMTP Port - the port for your mail server, usually 25 Encryption - if you want to enable SSL/TLS encryption for the mail server Authentication - check it for mail server authentication Username - the username for your SMTP server Password - the password for your SMTP server
What causes error ‘SMTP connect() failed’ in WordPress
The default mailer is PHPMailer in WordPress and many sites use it to send mails. But it can give ‘SMTP connect() failed’ error if PHPMailer is unable to contact the SMTP server.
Also, if the settings for the SMTP server is not configured correctly, it will not send mails successfully from the server and give ‘SMTP connect() failed’ error.
The error ‘SMTP connect() failed’ can be caused due to the many reasons, which we’ll discuss one by one.
Wrong username and password given in SMTP authentication. SMTP port blocked in mail server firewalls. SSL/TLS not support in mail server and encryption is enabled in WP setting. Security restrictions by 3rd party servers such as gmail or email apps. Upgrades to WordPress plugin or PHPMailer versions that have enhanced security features or bugs.