Joomla is a content management system which is used to create websites and applications. In this open source platform, to perform functions such as contact form submission or password resets, emails are used. When the email submission fails, the Joomla ‘SMTP connect () failed’ gets displayed. Developers usually come across such an error, while submitting a contact form or so.
In order to send emails, Joomla uses PHP mail function. From the Joomla administrator dashboard, the settings for PHP Mail can be changed. First, log into Joomla as an admin user and follow the below procedures.
System -> Global Configuration – > Server
The PHP Mail along with its corresponding settings can be seen under ‘Mail Settings’. Even though Joomla ‘SMTP connect () failed’ is a commonly seen error, it affects Joomla developers. The blog provides you everything you need know to fix the error.
The Reason Behind Joomla ‘SMTP Connect () Failed Error
In order to avoid spamming, the PHP mail function is disabled as a server security measure and this default Mailer will not work in sending emails. For this reason, the developers configure SMTP as the Mailer. In the drop down, Instead of PHP mail, choose SMTP as a mailer. SMTP server needs to be configured correctly or the email sending turns out to be a futile attempt. The attempts to send mail through the contact form or password reset forms may result in a Joomla ‘SMTP connect () failed error. The incorrect filling of the field ‘SMTP Security’ in the ‘Mail Settings’ may also cause the error ‘Joomla SMTP connect () failed’. The error may happen due to other reason too. It includes:
- Usage of wrong password and username during the SMTP authentication.
- The blocked SMTP port in server firewalls.
- Configuring mail server which does not support SSL/TLS.
- The practice of 3rd party servers and applications which are not secured.
- Use of Joomla or PHP Mailer versions which lacks security features or bugs.
How to Manage the Error Joomla ‘SMTP Connect () Failed
This session guides you to avoid the error Joomla ‘SMTP connect () failed. Select the Mailer as ‘SMTP’ from the Joomla administrator panel and enter host, username, and password through the following steps:
System -> Global Configuration – > Server -> Mail Settings
Host and Port Settings of SMTP
In the Host section, enter the name of your mail server. Usually, it is the ‘domain name’ or mail ‘mail.domain.com’. Make sure the DNS for SMTP host resolves correctly as well. Enable the SMTP port number as 25, which is the default SMTP port. In order to avoid spamming, for mail servers with custom ports such as 587, use that port. Using firewall rules, certain mail servers restrict the access to their port 25 and for that, your IP should be white listed in the firewall. It helps to avoid the connect error. In order to confirm that the connectivity is proper, use the following command:
telnet domain.com 25
Once, you are sure that the SMTP connection is working fine, give correct hostname and port number. If the connectivity fails, the mail delivery will fail with an error message.
Authentication details of SMTP
Turn the authentication ‘ON’, so that the email server can validate the user before allowing them to connect and send mails. Then give email username and password. In the case of non-default accounts, enter the full ‘firstname.lastname@example.org’. If the email password is changed or updated due to security reasons, change the password in mail settings too. If you have submitted the wrong authentication details, Joomla fails to send mails and shows the error message.
Security settings of SMTP
It is recommended to choose SMTP with SSL/TLS protocol for secure email transmission. So, from the drop-down for ‘SMTP Security’, choose ‘SSL/TLS’ option. It is not suitable for some email servers and mails may not get delivered.
In order to verify the SSL certificate for the mail server, use the command:
openssl s_client -starttls smtp -crlf -connect mail.domain.com:25
The usage of self-signed or expired certificates can also cause failure in mail delivery and display of SMTP connect () failed error. For that, configure SSL for your mail server properly or change ‘SSL/TLS’ in the SMTP Security settings as ‘none’.
The Support towards 3rd Party Apps
Certain things need to be taken care of, if you are using Gmail server instead of your own mail server. It includes the enabling of the ‘Authentication – Gmail’ plug-in. Follow the below steps in order to change the authentication.
Extensions -> Plug-in Manager -> Authentication – Gmail option.
Gmail server rejects connection attempts from some mail client apps such as a mobile application where the user have to use secure apps or need to loosen the security measures. Follow the steps,
My Account -> Less Secure Apps -> Turn on the option ‘Access for less secure apps’.
These steps help you to loosen the security settings. It helps the user to avoid SMTP connect failed’ errors while sending emails using Gmail.
The variants for the error ‘SMTP connects () failed’ include ‘SMTP Error: Could not connect to SMTP host’ and Called Mail () without being connected. Along with the configuration settings, the safety precautions which are needed to take during Joomla or PHPMailer upgrades are also important. Taking backups and doing test installs before upgrading the production server is important because every new version comes with new bugs or features. So with every improvement which you make with your new version, your security too increases. Adhering to latest technologies help you to keep your server away from external threats. Get the assistance of the skilled server administrators and ensure the protection of your server.