Pipe email to PHP script to be parsed
I am looking to pipe emails sent to an address at a specific subdomain to a php script, my control panel (cPanel) has an option to pipe such emails to a php script. I just need help finding examples on how to retreive the email contents piped to my script and how to parse the email to make a MySQL entry for it. Specifically I am working on developing a help desk system and i will need to seperate the sender, subject, and email body (ignoring any quoted contents of the body) to create a ticket in my db.
Any idea where I can find a function or class to do this. I need it to be GPL v2 or a compatible license as the code will be used in a project I am developing that I will release as GPL v2.