I've created a simple contact form that should be sending emails via php to me however, when I attempt to send/submit the form I continue to get the "message failed" output and have confirmed nothing is coming to my gmail inbox.
I have gone into my host server (heartland) and tried updating the Php.ini Port to (25 and 2525) and changed my SMTP to the host mail server. I've checked my error log and resolved any errors reported on it. I'm unsure if the issue lies within my host server or my actual php/form code.
Form Code
<h2>Contact Form</h2>
<form id="contactForm" method="POST" action="formHandler.php">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<input type="text" class="form-control" id="name" name="name" placeholder="Name" required data-error="Please enter your name">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input type="text" placeholder="Email" id="email" class="form-control" name="email" required data-error="Please enter your email">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<input type="text" placeholder="Subject" id="msg_subject" class="form-control" required data-error="Please enter your subject">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<textarea class="form-control" id="message" name="message" placeholder="Your Message" rows="5" data-error="Write your message" required></textarea>
<div class="help-block with-errors"></div>
</div>
<div class="submit-button">
<button class="btn btn-common" id="submit" type="submit" value="submit" target="_blank">Send Message</button>
<div id="msgSubmit" class="h3 text-center hidden"></div>
<div class="clearfix"></div>
</div>
</div>
</div>
</form>
PHP Code
<?php
if(isset($_POST['submit'])){
$to = "myemail@gmail.com";
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent=" From: $name \n Email: $email \n Message: $message";
$subject = "Contact Form";
$mailheader = "From: $email \r \n";
mail($to, $mailheader, $subject, $formcontent);
echo "<p>Thank you for contacting me!</p>";
echo "<p>I will reply to your inquiry in 24-48 business hours.</p>";
echo "<a href='form.html' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
}
else{
echo "<p> Message Failed to Send.</p>";
echo "<a href='form.html' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
}