I want to use php and HTML to create a contact page so users can send me an message directly from the website to my email-account
The only problem I have is that, it doesn't send any messages to my email-inbox(no errors on page)
Here is the code:
HTML(no css style): INDEX.html
<!DOCTYPE html >
<html>
<head>
<title>Contact US</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<div id="page-wrap">
<div id="contact-area">
SEND US A MESSAGE:
<form method="post" action="contactengine.php">
<label for="Name">Name:</label>
<input type="text" name="Name" id="Name" />
<label for="City">City:</label>
<input type="text" name="City" id="City" />
<label for="Email">Email:</label>
<input type="text" name="Email" id="Email" />
<label for="Message">Message:</label><br />
<textarea name="Message" rows="20" cols="20" id="Message"></textarea>
<input type="submit" name="submit" value="Submit" class="submit-button" />
</form>
</div>
</div>
</body>
</html>
PHP: contactengine.php
<?php
$EmailFrom = "JhonDoe@domain.com";<-- not sure about this one
$EmailTo = "MyEmail@domain.com";
$Subject = "WebSite Message";
$Name = Trim(stripslashes($_POST['Name']));
$Tel = Trim(stripslashes($_POST['Tel']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "
";
$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "
";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "
";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "
";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
?>