Postfix:向 PHP 发送电子邮件
您好,
有人知道向我的 postfix 服务器发送电子邮件,然后打开 PHP 脚本来处理该电子邮件的好方法吗?我可以执行 cron,但我更喜欢立即执行...
任何指示都非常感谢。
预先非常感谢,
Greetings,
Anyone know of a good way to send an email to my postfix server which then opens a PHP script to process this email? I could do cron, but I'd prefer to do it instantly...
Any pointers greatly appreciated.
Many thanks in advance,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您也许可以使用 .forward,但最简单的方法可能是配置 procmail。
编辑:这里有一个示例 .procmailrc 规则可能会有所帮助:
如果电子邮件来自 [email protected] ],然后它将被传递给 php 脚本。由于这是通过可与邮件服务器集成的 procmail 完成的,因此 MySql 设置不应影响任何内容。
You may be able to use a .forward, but probably the easiest way is to configure procmail.
Edit: here's a sample .procmailrc rule that may help:
If the email comes from [email protected], then it will get passed to the php script. Since this is done from procmail which can be integrated with the mail server, the MySql setup shouldn't impact anything.
当设置这样的东西时,你有两个选择。您可以通过管道将邮件发送到 php 处理程序,如果您必须一次处理大量邮件,这会有点危险,否则您会遭到邮件轰炸。就像 @B Mitch 所说, .forward 文件就可以解决问题。
或者,您可以使用类似
Zend_Mail_Storage
的东西来连接到邮箱,就像它是客户端一样。 Zend 还提供了一些有用的帮助器来解析邮件。When setting up something like this, you have 2 options. You can either pipe mail out to a php handler, which is a little dangerous if you have to process a lot of mail at once, or you get mailbombed. Like @B Mitch said, a .forward file will do the trick.
Alternatively, can you use something like
Zend_Mail_Storage
to connect to a mailbox as if it were a client. Zend also supplies some useful helpers for parsing mail.有多种选择;最简单的方法是使用包含以下内容的 .forward 文件:
|/路径/到/你的/脚本
在您用户的 $HOME 中。
缺点:每封邮件调用一次
优点:它仅由一个接收者调用,并且许多参数是使用环境变量传递的。
There are several options; the easiest being to use a .forward file containing:
|/path/to/your/script
in the $HOME of your user.
Drawback: It's invoked once per mail
Advantage: It's called with exactly one recipient and many parameters are passed using environment variables.