I apologize in advance for any rookie mistakes, as this is my first real attempt at piecing together a HTML / PhP contact form. I've scoured previous questions with identical issues and haven't found anything of substance.
The issue is the email is not sending. Things I've tried thus far: - Confirmed SMTP functions - Confirmed it's not a host-related issue - Used this exact form / PHP mailer on another template and it works fine - Checked spam folder
Here is the contact form itself:
<form action="contact.php" method="POST" id="contact-form" class="form">
<input type="hidden" value="" name="check">
<noscript>
<p class="noscript">JavaScript is required to use this form, please make sure your browser supports it.</p>
</noscript>
<p class="input">
<label for="name" class="label">Name</label>
<input type="text" name="name" id="name">
</p>
<p class="input">
<label for="company" class="label">Company</label>
<input type="text" name="company" id="company">
</p>
<p class="input">
<label for="email" class="label">Email</label>
<input type="text" name="email" id="email">
</p>
<p class="input">
<label for="phone" class="label">Phone</label>
<input type="text" name="phone" id="phone">
</p>
<p class="dark input">
<label for="title" class="label">Project Title</label>
<input type="text" name="title" id="title">
</p>
<p class="dark input">
<label for="timeline" class="label">Timeline</label>
<input type="text" name="timeline" id="timeline">
</p>
<p class="dark textarea">
<label for="details" class="label">Details</label>
<textarea name="details" id="details"></textarea>
</p>
<p>
<label for="send" class="send-label">Everything look good? Click send.</label>
<input type="submit" value="Submit" name="submit" class="button">
</p>
</form>
Here is the PHP mailer:
<?php
$field_name = $_POST['name'];
$field_company = $_POST['company'];
$field_email = $_POST['email'];
$field_phone = $_POST['phone'];
$field_title = $_POST['title'];
$field_timeline = $_POST['timeline'];
$field_message = $_POST['details'];
$mail_to = 'MyEmail@email.com';
$subject = 'Quote request from '.$field_name;
$body_message = 'From: '.$field_name."
";
$body_message .= 'E-mail: '.$field_email."
";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '.$field_email."
";
$headers .= 'Reply-To: '.$field_email."
";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. We will contact you shortly.');
window.location = 'contact.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please contact the webmaster.');
window.location = 'contact.html';
</script>
<?php
}
?>
Just for reference, the "MyEmail@email.com" is not the email I use. I used a substitute for privacy purposes.
Thank you!