推电子邮件给阿帕奇/ PHP服务器 [英] Push email to a apache/php server
问题描述
我们已经建立了需要经常检查电子邮件的Web服务。基本上,用户向我们发送电子邮件,服务器应基于该电子邮件做出行动。我们可以用一个crontab PHP脚本,以检查新邮件的每一分钟,用POP。但是,这是一种冒犯popserver和效率不是很高(1分钟是太长)。
但是,我读过有关周围使用移动设备的IMAP邮件推送。在我的情况不是一个移动设备,而是一个网络服务器。
我可以推送邮件到我的网络服务器并让它执行一个PHP脚本?我们使用Gmail作为POP / SMTP / IMAP服务器。
修改1 从答案,我们想通了:
-
必须有我的网络服务器检查电子邮件24/7运行的进程(守护进程)
-
这守护可以使用与Gmail通信:I)与NOOP coomand POP或ii)与IMAP IDLE命令
什么是最好的? POP或IMAP?谷歌似乎邀请更多使用IMAP的。
我不想过度使用的Gmail(什么是检查电子邮件的合理使用?每10secs?
email_scheduler.c
块引用>INT的main()
{
而(1){
睡眠(5); //每5秒的email_parser.php将得到执行。
系统(在/ usr /斌/ PHP -q /var/www/html/email_parser.php);
}
}
email_parser.php:
/ *使用任何电子邮件分析器
解析电子邮件喜欢MIME
根据你的目的的信息分析器
:参考:
http://www.phpclasses.org/browse/package/3169.html
* /
块引用>另外这里检查相关答案为<一个href=\"http://stackoverflow.com/questions/1047385/executing-php-script-from-c-program-and-store-the-results-in-to-a-variable\">more信息
We've built a web service that needs to check constantly for email messages. Basically, an user sends us an email, and the server should make actions based on that email. We could use a crontab PHP script that checks for new messages every minute, with POP. But that's kind of offensive to the popserver and not very efficient (1min is too long).
But, I've read about PUSH email using IMAP around mobile devices. In my case is not a mobile device but a webserver.
Can I push an email to my webserver and have it execute a PHP script? We're using GMail as POP/SMTP/IMAP server.
EDIT 1 from the answers, we figured out:
there must be a 24/7 running process (daemon) on my webserver checking for emails
this daemon may communicate with Gmail using: i) POP with NOOP coomand or ii) IMAP with IDLE command
What's the best? POP or IMAP? Google seems to invite more the use of IMAP.
I don't want to overuse gmail (what's their 'fair use' for checking email? every 10secs?
解决方案email_scheduler.c
int main() { while(1){ sleep(5); // every 5 secs the email_parser.php would get executed. system("/usr/bin/php -q /var/www/html/email_parser.php"); } }
email_parser.php :
/* Use any email message parser to parse the email messages like MIME message parser based on your purpose : Refer : http://www.phpclasses.org/browse/package/3169.html */
Also check relevant answers here for more info
这篇关于推电子邮件给阿帕奇/ PHP服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!