Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ligonsker's avatar

Connection could not be established with host when trying to send mail using SMTP

Hi,

I am trying to send mails using the test SMTP of the company. In the test server - it works and mails are sent. On the local PC, it fails with the following:

Unable to connect to smtp.company.com:20 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)

The config and .env are the same for both the test server and my local development PC, and when I try to ping using ping smtp.company.com I do get replies so it seems like it's working?

Local is XAMPP - could that be related to that as well?

Thanks

0 likes
3 replies
gych's avatar

First try to clear you config, php artisan config:clear And make sure you're using the correct port for the smtp connection.

1 like
Snapey's avatar
Snapey
Best Answer
Level 122

Speak to your network admins, there may be firewall rules in place on the mail server that limits who can connect to it.

1 like
Ligonsker's avatar

@Snapey You were right :) I was sure that if I can ping the IP address it means it's not firewall issue, but nonetheless it is a firewall issue. so I guess it's just that the ping works on a different port than the one blocked

Please or to participate in this conversation.