I used mail() function to receive mail from customers who are visiting my web page I use this code for mail function (mail.php). I use this same code from the first it worked for me in the beginning but not working now.
<?php
if(isset($_POST['submit'])){
$to = "******";
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>Enquiry</p>
<table>
<tr>
<td><strong>Name</strong></td><td>:</td><td>".$_POST['name']."</td>
</tr>
<tr>
<td><strong>Email ID</strong></td><td>:</td><td>".$_POST['email']."</td>
</tr>
<tr>
<td><strong>Mobile</strong></td><td>:</td><td>".$_POST['mobileno']."</td>
</tr>
<tr>
<td><strong>Message</strong></td><td>:</td><td>".$_POST['msg']."</td>
</tr>
</table>
</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: <****>' . "\r\n";
$headers .= 'Cc: *****' . "\r\n";
if(mail($to,$subject,$message,$headers)) {
echo '<script>
alert("Email Sent Successfully!");
window.location.href="../contact-us/contactus.html";
</script>';
} else {
echo '<script>
alert("Sorry your mail was not send kindly try again later.");
window.location.href="../contact-us/contactus.html";
</script>';
}
}
?>
here is my contact form code..
<form method="post" action="../mail/mail.php">
<p class="comment-form-author">
<label>Name<span>(required)</span></label>
<span class="icon-input">
<input type="text" name="name" required />
</span> </p>
<p class="comment-form-email">
<label>Email<span>(required)</span></label>
<span class="icon-input">
<input type="email" name="email" required />
</span> </p>
<p class="comment-form-mobileno">
<label>Mobile No.<span>(required)</span></label>
<span class="icon-input">
<input type="text" name="mobileno" required />
</span> </p>
<p class="comment-form-comment">
<label>Message<span>(required)</span></label>
<textarea name="msg">
</textarea>
</p>
<p class="form-submit">
<input type="submit" value="submit" name="submit">
</p>
</form>
when I click submit it shows me "Sorry, your mail was not sent kindly try again later."