Wow, that is quite the project! Just so you know, most people here are more than willing to give specific answers to specific questions. But to ask to someone to explain how to create a whole setup that you need is, well, alot.
I don't want to discourage you -- but... you will need to learn more about PHP and SMTP to understand how your program will work. If the PEAR extension is available through your host, I would highly recommend using it's mail functions over the standard mail() function. Here is the link to get you started:
http://pear.php.net/package/Mail
I hope that helps some! Let me know if you have more specific questions along the way...