简体   繁体   English

fsockopen 在端口 25 和 587 上被阻止

[英]fsockopen blocked on ports 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:我有一个非常简单的代码片段,它使用 fsockopen(或 stream_socket-client)连接到 SMTP 服务器,如下所示:

<?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.不幸的是,我无法连接到任何标准端口,例如 25,587 或 2525,因为我的两个主机提供商都在阻止使用这些端口的任何出站连接。 (I can only connect to internal SMTP server or localhost via 25 or 587) (我只能通过 25 或 587 连接到内部 SMTP 服务器或 localhost)

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).有没有办法使用不同的代码或端口来解决这个问题(我的意思是通过编程而不是像安装我自己的服务器那样)。

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.这些是标准 SMTP 端口,因此 SMTP 服务器不太可能接受其他端口上的连接。 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).您唯一的希望是要求您的提供商为您的帐户取消阻止这些端口,或者找到一个基于 HTTP 的外部代理服务器以连接到端口 80(除非您的提供商也阻止了该出站端口)。

Why can't you use the provider's internal SMTP server?为什么不能使用提供商的内部 SMTP 服务器? That is what you should be doing.这就是你应该做的。 Let it relay your messages to the other SMTP server for you.让它为您将您的消息中继到其他 SMTP 服务器。 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.现在越来越多的 SMTP 服务器被锁定以防止垃圾邮件和其他滥用行为,因此您可能会遇到不允许您直接连接到它们的 SMTP 服务器,即使您可以访问它们的端口,因为您不是该服务器的白名单上的提供商。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM