"One way to process the incoming messages is to configure the local mail server to start a PHP script when a message arrives on a given mailbox.
To achieve this, you need to learn specific details of how to configure your mail server because each mail server works in a different way.
For instance, if you use qmail mail server, you need to setup a .qmail file associated to the e-mail address that you want to handle. The .qmail file must contain the command that will be executed to start the PHP script that will handle the incoming messages.
...
An alternative solution to process received e-mail messages using PHP is to associate the incoming addresses to mailboxes accessible using POP3 or IMAP client scripts.
In this case, the messages are received and stored by the mail server, so they can be processed later by applications.
PHP scripts can use existing POP3 or IMAP client classes or extensions to regularly poll the mail server and retrieve the messages to perform the necessary processing tasks.
To perform this periodic poll, you can use the PHP CLI version command to start a PHP script by adding a task to cron on Linux and other Unix like systems, or the task scheduler on Windows.
Depending on how important the incoming messages may be, you may adjust the frequency of execution of the mailbox polling script."
http://www.phpclasses.org/blog/package/2/post/1-Process-incoming-email-messages-using-PHP.html