The email code appears to be applied correctly and should work. What hosting company are you using? Email won't work from your localhost, because XAMPP, MAMP, and WAMP don't include an SMTP server which is necessary to send email from a web page. It may work live if you have only been doing local testing.
If you are testing live, then it may be an issue with the smtp server settings in the email. If you let me know the hosting company I can try to look up the correct settings.