You do realize -- I hope -- that having a publicly accessible script that sends emails is a HUGE security risk on a server unless proper precautions are observed. It is an open doorway for DOS (Denial Of Service) attacks on the server (basically using all of its resources) and also to be used as a SPAM relay by anyone who finds it...
Just thought I'd point that out.
Having said all that, have you looked over the php.net
mail() function definition and discussions?
http://us.php.net/manual/en/function.mail.php
Good luck