good day! i can't send an email in php. i have this code:

mail("jjemphoung@yahoo.com","Testing","Hello","From: flatOne@yahoo.com");

when i run this the output is

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in E:\wamp\www\mail.php on line 4

i am using wampserver. i access this by typing my WAN ip (put online mode). what was that error? is there some configurations that i need to do first?

7 Years
Discussion Span
Last Post by sithembisophp

I think it is because you don't have a mailserver, only a webserver. If not WAMP includes a mailserver but I don't think it does :/


If you have a web host provider then try uploading the script there and then try sending it instead of doing it locally :)


if you are hosting the page yourself rather than with a company you need to install a mailserver on your machine


This code will workk for sure in a Server. For making it work in your local syatem , you need to install a mail server with your web server software .


thank u for the replies. sorry for my late reply. i've already fixed this problem. the problem is with my ISP. thank u all for the replies. really appreciate it!


I know this is becoming redundant, but the script is just fine. I also encountered the same problem, but all was fine once I uploaded it to the server.

It will work :-)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.