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

<html>
<body>
<?php
mail("jjemphoung@yahoo.com","Testing","Hello","From: flatOne@yahoo.com");
?>
</body>
</html>

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?

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 :)

you need to upload it in youre domain..

thanks for the replies. but how can i have a mailserver?

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

Member Avatar for rajarajan2017

Place your files on the web server and execute the php file it will work.

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 .

If your problem has been solved, please also mark the thread as solved :)

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 :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.