Your bot is going to get called on EVERY email message that is sent to the account.
Your bot MUST avoid "Returned Mail" loops.
First thing we need to do is set up your file to execute from the system as a script. You do this just as you would a PERL program. Place the shebang on the first line:
Next you need to open your stdin (php 4.3 makes the $stdin variable a global one so you do not need to fopen. However I'm running 4.2.1, so I do).
$stdin = fopen('php://stdin', 'r');
Setup your initial variables. You do not need to create these, but I find that my needs might change for the mailbot so having them available (should I require body parsing, other header information, etc. I don't have to rewrite anything).