This may be blasphemous but ...
I'm a PHP newb who is trying to learn more about coding. In the past, I've used a utility called FormsToGo. It can generate the PHP code (ASP and Perl too) and provides lots of options for recipients, conformation emails, attachments, security and more. It may be easier to let FTG generate your code instead of killing yourself trying to figure out how to make your own code work. You could then examine the code FTG generates to see how it's done. I believe the publisher offers a 30 free trial.
Here is a link to the product's features page:
http://www.bebosoft.com/products/formstogo/features.php
Hope this is helpful.