推电子邮件给阿帕奇/ PHP服务器 [英] Push email to a apache/php server

查看:181
本文介绍了推电子邮件给阿帕奇/ PHP服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经建立了需要经常检查电子邮件的Web服务。基本上,用户向我们发送电子邮件,服务器应基于该电子邮件做出行动。我们可以用一个crontab PHP脚本,以检查新邮件的每一分钟,用POP。但是,这是一种冒犯popserver和效率不是很高(1分钟是太长)。

但是,我读过有关周围使用移动设备的IMAP邮件推送。在我的情况不是一个移动设备,而是一个网络服务器。

我可以推送邮件到我的网络服务器并让它执行一个PHP脚本?我们使用Gmail作为POP / SMTP / IMAP服务器。

修改1 从答案,我们想通了:


  1. 必须有我的网络服务器检查电子邮件24/7运行的进程(守护进程)


  2. 这守护可以使用与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:

  1. there must be a 24/7 running process (daemon) on my webserver checking for emails

  2. 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屋!

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