PHP - Mail

PHP mail() function to send an email with PHP. The simplest way to do this is to send a text email. You can add contact form in your site it can send email using php mail function the following complete example to sent mail using php mail function.

Send Mail Using mail() Function

a complete contact form example using html and php mail function.


<html>
<head>
<title>Send Mail</title>
</head>
<body>
 <form method="post">;							
   Email: <input name="email" type="text" /><br />
   Subject: <input name="subject" type="text" /><br />
   Message:<textarea name="comment" rows="15" cols="40"></textarea><br />
   <input type="submit" value="Submit" />
 </form>
 <?php
  if (isset($_REQUEST['email']))  
{
  $my_email = "demo@example.com";
  $email = $_REQUEST['email'];
  $subject = $_REQUEST['subject'];
  $comment = $_REQUEST['comment'];
  mail($my_email, "$subject", $comment, "From:" . $email);
  echo "Thank you for contacting us!";
  }
?>
</body>
</html>
							
							
Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

You may also like this!