Using the mailparse to extract the data or use the read in nd process the input buffer one line at a time. A better and simpler approach depending on your mail server and whether it is passing the incoming mail through an LDA dovcot, procmail. The from and the body can be extracted and presented to your php with the from and subject as arguments to your script and the body of the message as input on stdin.
I am looking to parse email with php and learn about mailservers
how would I do this