I am on my localhost server. I am using this code below, but I never received the email.
I know its kinda late...
check if your localhost is configured to send email
On ubuntu terminal try executing following command
# apt-get install sendmail