fixed up mail script

current version:
-when running on server, now correctly sends and parses script
-includes error control for email.