Joomla is a commonly used content-management software for websites. In Joomla, emails are used for various purposes such as contact form submissions or password resets.
Joomla ‘SMTP connect() failed‘ is a commonly encountered email error in Joomla, when users try to submit a contact form in the website. Email fails to send, showing up this error.
By default, Joomla uses the PHP mail function to send mails. The settings for PHP Mail can be changed from the Joomla administrator dashboard.
Login to Joomla as admin user and go to the section ‘System’ -> ‘Global Configuration’ -> ‘Server’. Under ‘Mail Settings’, you can see PHP Mail as the Mailer and its corresponding settings.
What causes error Joomla ‘SMTP connect() failed’
In many servers where PHP mail function is disabled as a server security measure to avoid spamming, this default Mailer will not work to send mails.
That’s when we configure SMTP as the Mailer. From the drop-down for Mailer, choose SMTP instead of PHP Mail:
Even though SMTP mailer is chosen, if the corresponding settings for the SMTP server is not configured correctly, it will not send mails successfully from the server.
Attempts to send mails from the Joomla website via contact form or password reset forms would end up giving error “Error while sending the email. SMTP connect() failed.”
The error ‘Joomla SMTP connect() failed’ is often caused by incorrect filling of the field ‘SMTP Security’ in the ‘Mail Settings’.
SMTP connection can fail to establish due to a number of reasons:
- Wrong username and password given in SMTP authentication.
- SMTP port blocked in server firewalls.
- Mail server does not support SSL/TLS.
- Using 3rd party servers such as gmail or other insecure apps.
- Upgrades to Joomla or PHPMailer versions that have enhanced security features or bugs.
How to fix error Joomla ‘SMTP connect() failed’
Here, we’ll see how to set each of these settings properly to avoid email delivery errors from Joomla.
In Joomla administrator panel, under ‘System’ -> ‘Global Configuration’ -> ‘Server’ -> ‘Mail Settings’, choose Mailer ‘SMTP’ and enter host, user name and password. Turn on SMTP authentication section.
1. SMTP host and port settings
Enter the name of your mail server in ‘SMTP Host’ section. This is usually the ‘domain name’ or ‘mail.domain.com’. Make sure that the DNS for SMTP host resolves correctly.
Give port number as 25, the default SMTP port. For mail servers that use custom ports such as 587 for SMTP to avoid spamming, give that port.
It is also possible that certain mail servers restrict the access to their port 25 using firewall rules. In such cases, your IP should be white-listed in the firewall to avoid SMTP connect error.
To confirm that the connectivity to SMTP server and port is working fine, use the command:
telnet domain.com 25
Use the appropriate hostname and port number, after confirming that the SMTP connection is working fine. If the connectivity fails to establish, mail delivery will fail with the error ‘SMTP connect() failed‘.
2. SMTP authentication details
Every mail server has an authentication system to validate the users before allowing them to connect to it and send mails. In your Joomla Mail settings, turn this ON (YES).
Give the email account username and password. Enter the full ‘email@example.com’ as the username in case of non-default accounts.
Whenever the email account password is changed or updated for security reasons, do not forget to change the password in ‘Mail settings’ also.
If the authentication details given are wrong, Joomla will fail to send mails and give the error ‘SMTP connect() failed‘.
3. SMTP security settings
For secure email transmission, it is always advisable to choose SMTP with SSL/TLS protocol. So, choose ‘SSL/TLS’ option from the drop-down for ‘SMTP Security’.
But is some email servers, this SSL/TLS support may not be enabled. In those cases, if you choose ‘SSL/TLS’ security, mails may not get delivered.
To verify the SSL certificate for your mail server, use the command:
openssl s_client -starttls smtp -crlf -connect mail.domain.com:25
Using expired or self-signed certificates can cause the mail delivery using SSL to fail and give error ‘SMTP connect() failed‘.
So the solution in those cases is to configure SSL for your mail server properly or change the SMTP Security settings from ‘SSL/TLS’ to ‘None’, which is less secure one.
4. Support for 3rd party apps
If you are using gmail email server instead of your own mail server, then there are a few points to note. You have to enable the ‘Authentication – GMail’ plugin.
You can do this from the Admin Area: ‘Extensions -> Plugin Manager -> Authentication – GMail’ option.
Also, Gmail servers may not accept connection attempts from certain mail client apps such as mobile apps. In those cases, either use a secure app or loosen the security measures.
In ‘My Account’ -> ‘Less Secure Apps’ section, turn on the option ‘Access for less secure apps’ to loosen the security settings.
This will avoid Joomla ‘SMTP connect failed’ errors when trying to send emails from Joomla using Gmail.
Other variants for ‘SMTP connect() failed’ error are ‘Called Mail() without being connected’ or ‘SMTP Error: Could not connect to SMTP host.’
In addition to the configuration settings we’ve discussed, one important point to keep in mind is the safety precautions to take during Joomla or PHPMailer upgrades.
Since new versions may often come with features or bugs that may break a working website, its always important to take proper backups and do test installs, before upgrading in the production server.
At Bobcares, our hands-on experience with both Joomla customization and server administration has helped us to perform upgrades and fixes in websites without causing any business downtime.
If you’d like to know how to secure and manage your servers and customize your websites to prevent errors, we’d be happy to talk to you.
The post How to fix Joomla ‘SMTP connect() failed’ error while sending mails appeared first on Bobcares.