每当收到电子邮件时调用 php 脚本?

发布于 2024-08-21 11:06:12 字数 1126 浏览 2 评论 0 原文

我想要的是一项允许任何电子邮件发送到我的网站的服务(最好没有安装在服务器上,例如让第三方处理电子邮件,但如果需要专用服务器,我会尝试一下)作为 HTTP 请求重定向到我指定的 php 脚本

例如像这样的电子邮件

To: [email protected]
From: [email protected]
Subject: hello!
Message: Hey man whats up?

会发出 http 请求

http://example.com/notify.php

带有一些 POST 数据:

[email protected]&[email protected]&subject=hello!&message=Hey man whats up?

我想避免每分钟轮询,因为我相信这将是一个主要的消耗在服务器上。是否有任何现有的邮件服务器或服务具有此类功能?我的另一个计划是实现我自己的邮件服务器,但这似乎是一个巨大的项目来支持这一点。

What I would like is a service (preferably something not installed on a server like just letting a third-party handle e-mails but if a dedicated server is necessary I'll give it a shot) that allows any e-mails to my site to be redirected as a HTTP request to a php script I specify

For example a e-mail like this

To: [email protected]
From: [email protected]
Subject: hello!
Message: Hey man whats up?

Would make a http request to

http://example.com/notify.php

With some POST data:

[email protected]&[email protected]&subject=hello!&message=Hey man whats up?

I'd like to avoid polling every minute as I believe this would be a major drain on the server. Is there any pre-existing mail server or service that has these sort of features? My other plan would be to implement my own mail server but that seems like a huge project to undertake just to support this.

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

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

发布评论

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

评论(2

三生一梦 2024-08-28 11:06:12

在 MTA 中设置管道别名:

autoprog:      |myscript.php

此时,您可以让脚本解析电子邮件并打开一个 URL,并将其正确编码到查询字符串中。或者它可以直接处理电子邮件。

Set up a pipe alias in your MTA:

autoprog:      |myscript.php

At that point you can have your script parse the email and open a URL with it properly encoded into the query string. Or it could just process the email directly.

A君 2024-08-28 11:06:12

每分钟轮询邮件服务器以检查收件箱不应该成为系统的主要消耗。大多数电子邮件客户端正是这样做的。如果电子邮件服务器是 IMAP、POP3 或 NNTP,并且您想使用 PHP 查询收到的邮件,则可以使用 PHP 的 IMAP 扩展

Polling a mail server every minute to check an inbox shouldn't be a major drain on the system. Most email clients do exactly that. If the email server is IMAP, POP3, or NNTP, and you want to use PHP to query for received mail, you could do the polling using the IMAP extension for PHP.

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