Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection could not be established with host mail trap.io [permission denied #13]

I am trying to connect to mailtrap.io from CentOS server to send emails. The following error occurs:

"Connection could not be established with host mail trap.io [permission denied #13]"

Any ideas how to solve it?

like image 960
Marta Méndez Simón Avatar asked Sep 02 '25 02:09

Marta Méndez Simón


1 Answers

This could be due to SELinux blocking the connection.

I had the same issue and this solved it:

First check to see if httpd can send mail (if it is on or off)

$> getsebool httpd_can_sendmail
$> getsebool httpd_can_network_connect

If the response is: OFF then you could turn it ON as follow:

$> sudo setsebool -P httpd_can_sendmail 1
$> sudo setsebool -P httpd_can_network_connect 1

My source for this solution was Could not connect to SMTP host

like image 156
Dan Avatar answered Sep 05 '25 07:09

Dan