douzhang3822 2012-10-17 17:18
浏览 68

fsockopen在端口25和587上被阻止

I have a very simple snippet of code which connects to a SMTP server using fsockopen (or alternatively stream_socket-client) that looks like this:

<?php
$url = gethostbyname("mx6.go2.pl");
echo $url;
$fp = fsockopen($url, 587, $errno, $errstr, 10);
if (!$fp) {
echo "port is closed or blocked"
} else {
echo "port is open and available";
fclose($fp);
}
?>

Unfortunately, I cannot connect to any of the standard ports like 25,587 or 2525 because my both host providers are blocking any outbound connections using those ports. (I can only connect to internal SMTP server or localhost via 25 or 587)

Is there a way to go round this problem using different code or ports (I mean programmatically and not something like installing my own server).

Cheers,

Marcin

  • 写回答

1条回答 默认 最新

  • doujiayuan8415 2012-10-17 17:29
    关注

    If your provider blocks those outbound ports, there is nothing you can do about that. Those are the standard SMTP ports, so it is unlikely that the SMTP server is accepting connections on other ports. Your only hope is to either ask your provider to unblock those ports for your account, or else find an external HTTP-based proxy server to connect to on port 80 (unless your provider blocks that outbound port as well).

    Why can't you use the provider's internal SMTP server? That is what you should be doing. Let it relay your messages to the other SMTP server for you. More and more, SMTP servers are being locked down nowadays to prevent spamming and other abuses, so you are likely to run into SMTP servers that do not allow you to connect directly to them even if you can reach their ports, because you are not a provider on that server's whitelist.

    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决