Try this. I changed your code around a little bit. The way you had it was saying something like, if they filled in an email address then to get all the variables and then mail it. You also had it to where if the mail sent to say that id sent successfuly, but if it didn't to say there was an error.
First things first. You don't need to have the if mail part, because the mail will be sent no matter what. I guess you can just look at the code I made and figure it out.
Second: Yes, you have to have it on the server to test it out since it's a php code.