How to fix Joomla ‘SMTP connect() failed’ error while sending mails
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 ‘firstname.lastname@example.org’ 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‘.
Bobcares provides Outsourced Hosting Support and Outsourced Server Management for online businesses. Our services include Hosting Support Services, server support, help desk support, live chat support and phone support.