SMTP Error: Could not connect to SMTP host. Failed to connect to server

gisli.broncomedia47 15 Jun, 2025

My forms just started giving me this error "SMTP Error: Could not connect to SMTP host. Failed to connect to server"

The testmail in Joomla is working fine, no problems. Debug is not reporting anny strange behaviors, I just get this message upon submitting!It is the same for my forms and the demo forms, anny Idés? Using Joomla 5.3.1 and no update between working and not!

Best regards

Gibban

Max_admin 15 Jun, 2025

Do you have SMTP enabled in the Joomla global config ? does the test mail get sent using the SMTP server ? you can check this after you receive the test mail in the message details.

if yes then please check that your ChronoForms email is using the same Test Email settings, the Recipient, the From name & Email

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
gisli.broncomedia47 15 Jun, 2025

Yes the SMTP system in Joomla is working fine!And this is from the Submit tab.

Max_admin 16 Jun, 2025

Please remove the "From Settings" from your Email setup, and change the Recipients to some address @Gmail.com, does it work ?

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
gisli.broncomedia47 18 Jun, 2025
Answer
1 Likes

The problem is found in the error log:

Error in Mail API: Connection: opening to localhost:25Connection failed. Error #2: stream_socket_client(): Unable to connect to localhost:25 (Connection refused)

Solution of this problem:

In server CLI:

sudo apt update

sudo apt install postfix

During install, choose:

"Satellite system"
Use your SMTP settings (smtp.mail.com:587)

This will make localhost:25 forward emails through your working SMTP.

sudo nano /etc/postfix/main.cf

Add these lines at the end:

relayhost = [smtp.mail.com]:587

smtp_use_tls = yes

smtp_sasl_auth_enable = yes

smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

smtp_sasl_security_options = noanonymous

Save and exit (Ctrl+X, Y, Enter)

Create password file:

sudo nano /etc/postfix/sasl_passwd

Add this line:

[smtp.mail.com]:587 mail@mail.com:YOUR_PASSWORD

Secure the file:

sudo postmap /etc/postfix/sasl_passwd

sudo chmod 600 /etc/postfix/sasl_passwd*

sudo systemctl restart postfix

Problem solved! Case closed!

Max_admin 19 Jun, 2025

I'm glad you solved it, thank you for posting the solution!

normally the SMTP should work fine using the PHP app (Joomla with phpmailer), no need to set SMTP configuration in postfix

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
You need to login to be able to post a reply.