None of your basic MTAs will support POP3 or IMAP. Classic MTAs all only support SMTP. However, add-ons are available for these protocols.
Under Debian I would always recommend exim. It is the default MTA, has good support for virus scanning (with Clam AV), spam filtering (spamassassin) and greylisting. This will by default deliver either to a smarthost or to local mailboxes.
You can then install solutions for POP3 (I recommend qpopper, but there are many alternatives, e.g. teapop3) and IMAP (I recommend courier-imap). You could also use an entire suite based on courier.
In terms of automating account setup via PHP, have a look at vexim. That's a package that provides a simple-to-use web interface for exim administration.
Now here's my final word: if you are doing this to learn about various MTAs and related aspects, then go ahead and do it. If you are doing this for a few users and a real mail solution, I would much rather recommend you go and get yourself some accounts with a commercial mail provider. I have heard very good stuff about gmail, but they are not the only ones. Administration of a live mail server is not something you do once and then go away. It is a day-to-day job, requires lots of knowledge and dedication, and if you get one small bit wrong, the hackers will be all over you.