I am using following script to send contact us form details through email from my website.
But script is not working, getting
Error sending mail
message.
Not getting what is the problem here:
<?php
$MailToAddress = "ToEmailID";
$redirectURL = "index.html";
$MailSubject = "Inquiries - Contact Us";
$redirectURL = "index.html";
$message_body = "NAME: ".$_POST["name"]."\r\n";
$message_body .= "E-Mail: ".$_POST["email"]."\r\n";
$message_body .= "SUBJECT: ".$_POST["subject"]."\r\n";
$message_body .= "MESSAGE: ".$_POST["message"]."\r\n";
if (!mail($MailToAddress, $MailSubject, $message_body)) {
echo "Error sending e-mail!";
}
else {
header("Location: ".$redirectURL);
}
?>
And here is the form:
<form action="submit.php" class="contact-form" method="post">
<div class="col-md-4"><input id="senderName" name="name" placeholder="name" type="text" /></div>
<input id="senderEmail" name="email" placeholder="email address" type="text" />
<input id="subject" name="subject" placeholder="subject" type="text" />
<textarea id="message" name="message" placeholder="Message" required="" rows="6"></textarea>
<input class="btn-regular alignleft contact_button" type="submit" value="SUBMIT" name="submit">
</form>