如何从防火墙严格的网络中使用 PHP 发送电子邮件?

发布于 2024-07-18 06:43:36 字数 465 浏览 9 评论 0原文

我希望从我的本地主机发送电子邮件(使用 PHP 邮件功能),但我不能这样做,因为我没有邮件服务器。 此外,我需要能够通过严格防火墙的网络发送电子邮件(我还不知道到什么程度)。

我的想法是利用“QK SMTP Server 3”并让它使用我作为“中继服务器”的外部服务器。 这行得通吗? 有更简单的选择吗?

如果我的方法没问题的话。 我想知道如何在我的服务器上打开端口 25,以便它可以接收此请求。 通过执行此命令,我得到:

[root@balder296 ~]# service iptables status
Firewall is stopped.
[root@balder296 ~]#

感谢您的帮助和建议。

Solved

Hotmail(令人惊讶)提供免费中继服务。 我希望当我测试这个时这对我有用! 但外部邮件服务器是最佳选择。

I wish to send an email from my localhost machine (using PHPs mail function) but I can not do this since I don't have a mail server. In addition, I need to be able to send emails through a network that is heavily firewalled (to what extent I do not know yet).

My idea is to make use of "QK SMTP Server 3" and get that to use an external server I have as a "Relay server". Will this work? Is there an easier option?

If my approach is Ok. I would like to know how I can open port 25 on my server so it can receive this request. By executing this command I get:

[root@balder296 ~]# service iptables status
Firewall is stopped.
[root@balder296 ~]#

Thank you for any help and advice.

Solved

Hotmail (surprisingly) provides a free relay service. I hope this works for me when I test this! But an external mail server is the way to go.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

蓦然回首 2024-07-25 06:43:36

确定您是否可以通过端口 25 (SMTP)

  • telnet gmail-smtp-in.l.google.com 25(这是 Gmail 服务器之一)

连接到互联网如果您能够打开连接后,您只需安装邮件服务器并使用 mail() 函数发送消息即可。

  • yum install postfix(例如,根据您的“服务”备注,我假设您正在运行 Redhat 或 Centos)

如果您无法在端口 25 上连接到 Internet 邮件服务器,您可以尝试查找内部邮件中继(这是您必须自己找到的东西,具体取决于您的网络)。

那时你有两个选择。 如果您在邮件服务器(/etc/postfix,如果您使用 Postfix)中定义了“relay”参数,则可以将内部 mail() 函数与本地邮件服务器一起使用。

另一种选择是遵循本指南并获取 PHP 将消息发送到内部继电器。

Figure out if you can connect to the Internet on port 25 (SMTP)

  • telnet gmail-smtp-in.l.google.com 25 (this is one of the Gmail servers)

If you're able to open up a connection, you can simply install a mail-server and use the mail() function to send messages.

  • yum install postfix (for example, from your 'service' remark I assume you're running Redhat or Centos)

If you're unable to connect to Internet mail servers on port 25, you can try finding an internal mail relay (this is something you will have to find yourself, depending on your network).

At that point you have two options. You can use the internal mail() function with your local mail server if you define the 'relay' parameter in your mails-server (/etc/postfix if you're using Postfix).

The other option is to follow this guide and get get PHP to send the messages to an internal relay.

2024-07-25 06:43:36

也许有一个(好的?)原因可以解释为什么您所在的网络受到严格的防火墙保护。

你为什么不问问网络上的人发送邮件有什么好的解决方案呢?

Maybe there is a (good?) reason which explain why the network where you are is heavily firewalled.

Why don't you ask guy's from the network what is the good solution to send mail ?

挽你眉间 2024-07-25 06:43:36

如果您有 Google Mail 帐户,则可以使用 Swift Mailer 来发送电子邮件。

If you have a Google Mail account, you can use it to send emails using Swift Mailer.

就是爱搞怪 2024-07-25 06:43:36

您需要一台位于防火墙后面运行邮件服务器的计算机。 最好这应该是它的全部用途。 虽然它后面的其他所有内容都应该被阻止在端口 25 上打开传出连接,但这个应该被阻止。 让运行应用程序的计算机上的邮件服务器通过该计算机进行中继。 我在一家托管公司工作,这就是我们使用共享托管服务器所做的事情。 这样,您就可以跟踪任何发出的邮件,以确保防火墙后面没有任何人在做任何不正当的事情。

如果你好意地询问,你友好的邻居系统管理员几乎肯定会设置这个。

You'll need a machine behind the firewall running a mailserver. Preferably this should be all it should be used for. While everything else behind it should be blocked from opening outgoing connections on port 25, this one should. Have the mailserver on the machine running your application relay through that machine. I work for a hosting company, and that's what we do with our shared hosting servers. This way, you can track any outgoing mail to ensure that nothing behind the firewall doing anything underhand.

You're friendly neighbourhood sysadmin will almost definitely set this up if you ask nicely.

那片花海 2024-07-25 06:43:36

如果这是针对公共应用程序,请记住,即使您可以获得出站 SMTP 访问权限,您也可能会遇到问题。 反垃圾邮件保护对网络行为变得相当挑剔。 例如,网络上有一个有效的 SMTP 服务器,而您设置了另一个服务器,如果这两个服务器在网络外部看起来具有相同的 IP 地址,则可能会给这两个服务器带来麻烦。 一些主要的黑名单会自动阻止似乎拥有多个服务器的地址。

如果您试图绕过网络管理员,那么您最多可能拥有一个脆弱的系统。 根据您的网络规则/设置,您也许能够设置 SMTP 服务器包以从网络上的另一个电子邮件服务器中继消息。 这应该需要与网络或电子邮件管理员合作。

If this is going to be for a public application, keep in mind that even if you can get SMTP access outbound you are likely to run into problems down the road. Anti-SPAM protections have gotten fairly picky about network behavior. For example is there is a valid SMTP server on the network and you setup another that may cause trouble for both servers if they appear to have the same IP address from outside the network. A couple of the major blacklists automatically block addresses that appear to have more than one server on them.

If you are trying to get around a network admin, at best you are likely to have a fragile system in place. Depending on your network's rules/setup you MIGHT be able to setup your SMTP server package to relay messages off another email server on the network. This should require working with the network or email admin.

铁轨上的流浪者 2024-07-25 06:43:36

我过去使用过 SwiftMailer,然后设置一个通用的 Gmail 帐户来发送邮件。 我发现的一件事是,最好将发件人地址保留为您设置的 Gmail 帐户,否则垃圾邮件过滤器往往会丢弃电子邮件。

I've used SwiftMailer in the past and then setup a generic gmail account to send the mail through. The one thing I found out is that it's best to keep the from address as the gmail account you setup otherwise spam filters tend to trash the email.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文