Saturday, December 31, 2016

enquiry Mail from users to website using php mail


  In This Article i have explain the how to send enquiry mail in php.

  //HTML form for input value
   <form class="contact_form slideanim" name="frm_contact" method="post">

<div class="message">
<div class="col-md-6 col-sm-6 grid_6 c1">
<input type="text" class="text" name="name"  required="true"  placeholder="Name" onFocus="this.value = '';" onBlur="if (this.value == '') {this.value = 'Name';}">
<input type="text" class="text" name="email"  required="true"  placeholder="Email" onFocus="this.value = '';" onBlur="if (this.value == '') {this.value = 'Email';}">
<input type="text" class="text" name="phone"  required="true"  placeholder="Phone" onFocus="this.value = '';" onBlur="if (this.value == '') {this.value = 'Phone';}">
</div>

<div class="col-md-6 col-sm-6 grid_6 c1">
<textarea placeholder="Message" name="message" required id="message" onFocus="this.value = '';" onBlur="if (this.value == '') {this.value = 'Message';}">Message</textarea>
</div>
<div class="clearfix"></div>
</div>

<input type="submit" class="more_btn" name="Submit_form" id="Submit_form" onsubmit="Blank_TextField_Validator()" value="Send Message">
</form>

 Php Code for sending email..

<?php
if(isset($_POST['Submit_form']))
{

$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$client_message=$_POST['message'];
if(empty($name)){
?>
<script>
 alert("Name Is Required ! ");
</script>
<?php
}


$to = "toemail@gmail.com , brijpal.xantatech@gmail.com";
$subject = "Client Mail World InfoTech";
$msg="Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$name."<br>Email:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$email."<br>Phone:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$phone."<br>><br><b>Client Message:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>".$client_message;
$message = "
<html>
<head>
<title>Info@World InfoTech.com</title>
</head>
<body>
<p>Query</p>

</body>
</html>
";

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// More headers
$headers .= 'From: <fromemail@gmail.com >' . "\r\n";
$headers .= 'Cc: xyz@gmail.com ' . "\r\n";

if(mail($to,$subject,$msg,$headers))
{
//echo "Mail Send";
?>
<script>
 alert("Your Message Has Been Send ! ");
</script>
<?php
}else{
?>
<script>
  alert("Error ! ");
</script>
<?php

}
}
?>

No comments:

Post a Comment

Featured Post

What is JavaScript? What is the role of JavaScript engine?

  The JavaScript is a Programming language that is used for converting static web pages to interactive and dynamic web pages. A JavaScript e...