We have built an internet service that must check constantly for e-mail. Essentially, an user transmits us an e-mail, and also the server should make actions according to that email. We're able to make use of a crontab PHP script that inspections for brand new messages every minute, with POP. But that is type of offensive towards the popserver and not so efficient (1min is simply too lengthy).

But, I have find out about PUSH email using IMAP around mobile products. During my situation isn't a mobile phone but a webserver.

Can One push an e-mail to my webserver and also have it perform PHP script? We are using GMail as POP/SMTP/IMAP server.

EDIT 1 in the solutions, we determined:

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

  2. this daemon may talk to Gmail using: i) POP with NOOP coomand or ii) IMAP with IDLE command

What is the best? POP or IMAP? Google appears to ask more using IMAP.

I'd rather not overuse gmail (what's their 'fair use' for checking email? every 10secs?

If you wish to use postfix as the MTA you are able to alias their email to the executable like this. It truly is not that hard to setup on the *nix box...

I have no training with IMAP, but needed to perform the same factor. Personally, I'd install Postfix and employ the pipe command (essentially allows you take a random script) to invoke a little http client that parses the e-mail and transmits it for your server.

You are able to replace postfix with whatever MTA you would like, obviously. The thing is: don't implement your personal email server. Make use of an existing one and employ its hooks to transmit the mail off and away to anywhere you want, yet it's you would like.

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 e-mail messages like MIME message parser determined by your own personal purpose : Refer : http://www.phpclasses.org/browse/package/3169.html */

Also check relevant solutions for more info

There's a classic (but great) article on Evolt about piping emails to some php script, which therefore will get the entire content from the email and may act onto it.

http://www.evolt.org/article/Incoming_Mail_and_PHP/18/27914/index.html