-1

i have a folder name php contains file name index.html on my desktop and i have install xampp in my C://xampp folder .Plz tell me how to structure php folder index.html contains this code. But this code not sending email .is there any problem in my folder structure php

<!Doctype html>
<html>
<head>
 <title>My email Page</title>
</head>
 <body>
  <div>
   <?php
     $email = "example@yahoo.com";
     $subject = "hope this works";
     $body = "i think all is well";
     $header = "from Ali@yahoo.com";
     mail($email , $subject, $body $header);
     echo "ok all well";
   ?>
 </div>
</body>
</html>
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
star5
  • 17
  • 3

2 Answers2

0

You need to get your xampp run your php script first. So change your index.html to index.php. When you visit your page from browser via http://localhost/php/index.php, you can see if that php snippet runs or not.

Highlight
  • 124
  • 4
0

If you are running on localhost such as XAMPP, then chances are the PHP mail function won't work as you do not have a mail service running, hence no mail will be sent. See Why mail() PHP function does not work with WAMP default installation?

Community
  • 1
  • 1
Nick Duncan
  • 829
  • 6
  • 17