I have written the following contact form. But it is or working. Please help me ….
<?php
if (isset($_POST['submit'])) {
$ToEmail = 'mymail@gmail.com';
$EmailSubject = 'Site contact form ';
$mailheader = "From: " . $_POST["email"] . "\r\n";
$mailheader .= "Reply-To: " . $_POST["email"] . "\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: " . $_POST["name"] . "<br>";
$MESSAGE_BODY .= "Email: " . $_POST["email"] . "<br>";
$MESSAGE_BODY .= "Comment: " . nl2br($_POST["comment"]) . "<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader)
or die("Failure");
echo "<p>Your message was sent.</p>";
}
?>
<form action="index.php?page=contacts" method="post">
<p>Your name:<br/>
<input name="name" type="text" size="32">
</p>
<p>Email address:<br/>
<input name="email" type="text" size="32">
</p>
<p>Message:<br/>
<textarea name="comment" cols="55" rows="8"></textarea>
</p>
<p>
<input type="submit" name="Submit" value="Send">
</p>
</form>
If you find any bug please let me know. Thanks in advance.
if mail() returns false, then your PHP isn’t configured properly. If you’re on a Windows host, you need to have valid
SMTPandsmtp_portsettings defined in your php.ini, and the SMTP server must be up and running.That, or you’re passing in bad values for the ‘To:’ or other headers that the SMTP server is rejecting outright.