Fsockopen sends mail

fsockopen("smtp.163.com", 25, "", "", 10);
false,
FSOCKOPENfalse
Php
Mar.30,2021

generally closes port 25. You need to ask your service provider whether port 25 is open


$handler = fsockopen('smtp.163.com', 26, $errcode, $errmsg, 10);
var_dump($errcode, $errmsg, $handler);

pfsockopen-Open a persistent network connection or Unix socket connection.

resource fsockopen (string $hostname [, int $port =-1 [, int & $errno [, string & $errstr [, float $timeout = ini_get ("default_socket_timeout")])

as you can see from the document, int & $errno and string & $errstr are reference types and cannot be assigned directly.

the result of execution in PHP 5.6 / PHP 7.1.16 (cli) is as follows

Fatal error: Only variables can be passed by reference in xxx.php on line 2

the modified code is as follows

<?php
$res = fsockopen('smtp.163.com', 25, $errno, $errmsg, 10);

var_dump($errno, $errmsg);
Menu