What you’d probably do is use procmail to send incoming email to a script.
In .procmailrc, you’d have:
| php $HOME/myscript.php
In myscript.php, you’d use fopen(‘php://stdin’, ‘r’) to read the standard input (which is the email)
I haven’t tried it in exactly this way, but hopefully that gives you an idea how to send an email to a program…