当新邮件到达时触发脚本 [英] Triggering A Script When New Mail Arrives

查看:297
本文介绍了当新邮件到达时触发脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当任何人发送邮件到 go@domain.com 时,我想运行一个php脚本(例如mail.php )。然后我将收到发件人,邮件正文和其他信息,我将在 mail.php *上使用它们。

I want to run a php script (for example mail.php) when anyone send a mail to go@domain.com . And then i will get sender, mail body and other informations, and i will use them on mail.php*.

我读了几个关于通过PHP的IMAP功能获取邮件的文章。
我可以写一个脚本,每隔一秒检查邮箱(通过cronjobs),并将未读邮件的数据发送到 mail.php 。但是我不想通过cronjobs这样做。

I read a few articles about getting mails via PHP's IMAP functions. I can write a script which checks mail box every second (via cronjobs) and send unread mail's datas to mail.php .But i don'T want to do it via cronjobs.

当有人自动发送电子邮件至 go@domain.com 时,是否可以触发 mail.php 脚本?

Can i trigger mail.php script when someone send an email to go@domain.com, automatically ?

(最近我在linux服务器上有一个经销商帐户(允许IMAP),但是如果真的,我可以买一台服务器(专用,vps,云等)需要它。)

(recently i have a reseller account on a linux server (it's allowing IMAP). But i can bought a server (dedicated, vps, cloud etc.) if I really need it.)

推荐答案

假设它是一个基于unix的主机,你可以在该帐户的主目录管道中有一个.forward文件电子邮件直接发送给脚本。这个脚本将通过它的STDIN读取电子邮件,然后从那里开始。

Assuming it's a unix-based host, you can have a .forward file in that account's home directory pipe the email directly to a script. This script would read the email via its STDIN and then go from there.

这里显示的一些示例: http://www.activecampaign.com/support/tt/kb/article/help-desk/version-25x-26x/setting-up-supporttrio/setting-up-your-server-to-forward-email- to-the-pipe-script

Some examples shown here: http://www.activecampaign.com/support/tt/kb/article/help-desk/version-25x-26x/setting-up-supporttrio/setting-up-your-server-to-forward-email-to-the-pipe-script

这篇关于当新邮件到达时触发脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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