On WebReference.com today there's a new tutorial about creating a PHP interface for sending and receiving emails directly from a mailer script.
In this tutorial you will learn how to create your own PHP Web mailer. You will learn the necessary steps for creating an email account and making connections to the server protocols for sending and receiving email. You also will get a listing of PHP commands that you can use to customize the Web mailer to your specifications.
The script makes manual connections to the servers instead of using something like mail and sends the raw commands to send via an SMTP server and fetch over a POP3 connection. There's also an example of making an IMAP connection and sending commands to get the current list of messages, current status and fetch the messages.