PHP and MySQL are both mutually exclusive, and even more so from an email server.
To use PHP to receive email and insert it to a MySQL Database, you would have to write PHP code that is going to connect to a POP3/IMAP box and receive email directly and read new emails, subsequently inserting them into the database for handling them as you wish.
Luckily for you there are a whole host of mail related extensions for PHP. Note that you will specifically want to look at the set of imap_*
methods (despite the name, they also work for POP3, etc).
I know, you could write your own SMTP server in PHP but who on earth wants to do that?