I have write code on my website contact us page but its not working.I check everything but still i am not receiving email when i try it my self.
I have this is Form:
<form id="contact-form" class="cform" method="post">
<label class="hide"
for="author">
Full Name
</label>
<input class="input-fields" id="full_name" name="full_name" type="text" required="required" placeholder="Full Name" value=""/>
<label class="hide" for="email">Email</label>
<input class="input-fields req-email" id="email" name="email" type="text" required="required" placeholder="Email Address" value=""/>
<label class="hide" for="subject_title">Subject title</label>
<input class="input-fields" id="subject_title" name="subject_title" type="text" required="required" placeholder="Subject Title" value=""/>
<label class="hide" for="comment">Message</label>
<textarea id="comment" class="input-fields form-control" required placeholder="Message" name="comment" cols="40" rows="200"></textarea>
<input name="submit" type="submit" id="submit-contact-info" class="contact-info-submit form-submit-button span2" value="Send message">
</form>
And this is php:
<?php
if(isset($_POST['submit'])){
$to = "mail@asrhouse.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$full_name = $_POST['full_name'];
$subject = $_POST['subject_title'];
$subject2 = "Copy of your form submission";
$message = $full_name . " wrote the following:" . "
" . $_POST['comment'];
$message2 = "Here is a copy of your message " . $full_name . "
" . $_POST['comment'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
$msgss= "Mail Sent. Thank you " . $full_name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>
This should help you understand how you needs to format the email. You are missing vital header information in your emails. I am going to guess either your emails are going to SPAM since the method you are using will probably push it to SPAM without the proper headers. Or hopefully this format can help you figure it out. We cannot do much for you if no errors are present and we don't know the configuration of your box. Maybe it does not support PHP Mail function?
<?php
$to = "somebody@example.com, somebodyelse@example.com";
$subject = "HTML email";
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "
";
$headers .= "Content-type:text/html;charset=UTF-8" . "
";
// More headers
$headers .= 'From: <webmaster@example.com>' . "
";
$headers .= 'Cc: myboss@example.com' . "
";
mail($to,$subject,$message,$headers);
?>