I'm trying to setup a form-to-email PHP code for a contact form and am having some difficulty with it. My script seems to run, but it's not actually sending any email. The file is saved under index.php and put in my public_html directory like all other files for my website. Furthermore, I have an email address using my domain name with my web host.
Here's how I spring the code and then, the code in question.
<form method="post" action="index.php">
<?php
// Check for submit
// if(filter_has_var(INPUT_POST, 'submit')){
if(isset($_POST['submit'])){
// Get Form Data
$name = htmlspecialchars($_POST['name']);
$email = htmlspecialchars($_POST['email']);
$phone = htmlspecialchars($_POST['phone']);
$website = htmlspecialchars($_POST['website']);
$message = htmlspecialchars($_POST['message']);
// Sending Email
$toEmail = 'admin@thomascaissie.com';
$subject = 'Contact Request From ' .$name;
$body = '<h2>Contact Request</h2>
<h4>Name</h4><p>'.$name.'</p>
<h4>Email</h4><p>'.$email.'</p>
<h4>Phone Number</h4><p>'.$phone.'</p>
<h4>Website</h4><p>'.$website.'</p>
<h4>Message</h4><p>'.$message.'</p>
';
//Email Headers
$headers = "MIME-Version: 1.0" ."\r\n";
$headers .="Content-Type:text/html;charset=UTF-8" . "
\r\n";
//Additional Headers
$headers .= "From: " .$name. "<".$email.">". "\r\n";
}
?>
Where is it that I made my mistake? My guess is I'm not even calling the script to actually send an email.