Honestly, you're better off looking at one of the webmail systems already out there and modifying it to fit your needs rather than writing something from scratch.
The email RFCs are a fun read (no, no they're not) and attachment handling has caused many developers to take up heavy drinking. Don't get me wrong, it can be done. Its just a lot of work and not something that you want to take on unless you have a bunch of time to dig deep into it.
However, if you wanted to write something quick and simple, I suggest setting up a linux box with an Imap or pop server and then accessing that mailbox with the appropriate PHP / Pear libraries. That will be the quickest way to get going.
But I would still recommend using one of the off the shelf solutions that are out there and hacking it up to fit your needs.