fork download
  1. <?php
  2. $host = 'mx1.mail.yahoo.co.jp';
  3. $port = 25;
  4. $timeout = 5; // 秒
  5.  
  6. echo "⏳ 正在测试连接 $host:$port ...\n";
  7.  
  8. $connection = @fsockopen($host, $port, $errno, $errstr, $timeout);
  9.  
  10. if ($connection) {
  11. $response = fgets($connection, 1024);
  12. echo "✅ 连接成功:\n$response";
  13. fclose($connection);
  14. } else {
  15. echo "❌ 连接失败:$errstr ($errno)\n";
  16. }
Success #stdin #stdout 0.03s 26020KB
stdin
Standard input is empty
stdout
⏳ 正在测试连接 mx1.mail.yahoo.co.jp:25 ...
❌ 连接失败:php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution (0)