每当收到电子邮件时调用php脚本? [英] Call a php script whenever an e-mail is received?

查看:181
本文介绍了每当收到电子邮件时调用php脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要的是一种允许任何电子邮件的服务(最好是没有安装在服务器上的东西,例如让第三方处理电子邮件,但如果有必要使用专用服务器,我会给它一个机会)到我的网站,作为HTTP请求重定向到php脚本,我指定了

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

例如这样的电子邮件

To: chris@example.com
From: anotherplace@another.site.example.org
Subject: hello!
Message: Hey man whats up?

将发出http请求

http://example.com/notify.php

有一些POST数据:

to=chris@example.com&from=anotherplace@another.site.example.org&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.

推荐答案

在您的MTA中设置管道别名:

Set up a pipe alias in your MTA:

autoprog:      |myscript.php

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

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.

这篇关于每当收到电子邮件时调用php脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆