Well, if it says localhost, do you have an SMTP server running on the same system as the PHP?
If not, find out your SMTP server (ask your sys admin or if you are running this PHP on your local machine, ask your ISP what your SMTP server is).
Then change "localhost" with the hostname or IP of your SMTP server.
-sridhar