Outgoing port is open on the firewall, how to unlock for PHP?

The goal is to send outgoing emails from my shared Mandrill host through SMTP using PHP, and I fully collaborate with the sys host administrators.

Current situation:

  • ✅ PHP can connect to smtp.mandrillapp.com 443 port (used for HTTPS)
  • ❌ PHP cannot connect to smtp.mandrillapp.com 587 port (used for SMTP)
  • ✅ PHP can connect to portquiz.net 443 port (used for HTTPS)
  • ❌ PHP cannot connect to portquiz.net 587 port (used for SMTP)
  • ✅ Telnet can connect to smtp.mandrillapp.com 443 port
  • ✅ Telnet can connect to smtp.mandrillapp.com 587 port

Telnet is verified by logging in with administrator rights and starting telnet HOST PORT. PHP is checked using the script below.

What configuration option for PHP can block outgoing connections on port 587? And how can we cancel this configuration?

<?php
// Test outbound server connections

// https://mandrill.zendesk.com/hc/en-us/articles/205582167-What-SMTP-ports-can-I-use-
$servers = array(
    array("ssl://www.google.com", 443),
    array("ssl://smtp.mandrillapp.com", 465),
    array("smtp.mandrillapp.com", 25),
    array("smtp.mandrillapp.com", 587),
    array("smtp.mandrillapp.com", 2525),
    array("smtp.mandrillapp.com", 443)
);

foreach ($servers as $server) {
    list($server, $port) = $server;
    echo "<h1>Attempting connect to <tt>$server:$port</tt></h1>\n";
    flush();
    $socket = fsockopen($server, $port, &$errno, &$errstr, 10);
    if(!$socket) {
      echo "<p>ERROR: $server:$portsmtp - $errstr ($errno)</p>\n";
    } else {
      echo "<p>SUCCESS: $server:$port - ok</p>\n";
    }
    flush();
}
?>
0
source share
1 answer

As far as I know, it is not possible to block any specific ports using PHP. (Perhaps using suhosin, but I never heard of this option.)

-, SELinux ? SELinux / / . , SMTP-, telnet root, PHP . CentOS, 80 PHP/Apache, curl/wget root, .

+1

All Articles