PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I doubt you wanto code the mail server, you can use Exim for that. I use Exim4, then pipe all incoming mail into a PHP script which looks up the user and puts it in a database.
Exim4 has system_filter which you can use to define your pipe for the incoming mail according to your desired criteria.