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: ".$name."<br>Email: ".$email."<br>Phone: ".$phone."<br>><br><b>Client Message:</b> <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