I am making a personal website and I am having some problems with getting the website to send me emails via my contact system. My PHP code is as follows:
<?php
$to = "recipients email here";
$subject = "Title";
$name = "Name: ".$_POST['name']."<br>";
$email .= "Email: ".$_POST['email']."<br>";
$message .= "Message: ".$_POST['note']."<br>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$success = mail($to, $subject, $message, $headers);
?>
And my HTML code is as follows:
<!-- Form Start -->
<div class="row mt-100">
<div class="col-lg-12 col-sm-12">
<div class="contact-form ">
<form method="post" class="box contact-valid" id="contact-form">
<div class="row">
<div class="col-lg-6 col-sm-12">
<input type="text" name="name" id="name" class="form-control" placeholder="Name *">
</div>
<div class="col-lg-6 col-sm-12">
<input type="email" name="email" id="email" class="form-control" placeholder="Email *">
</div>
<div class="col-lg-12 col-sm-12">
<textarea class="form-control" name="note" id="note" placeholder="Your Message"></textarea>
</div>
<div class="col-lg-12 col-sm-12 text-center">
<button type="submit" class="btn-st">Send Message</button>
<div id="loader">
<i class="fas fa-sync"></i>
</div>
</div>
<div class="col-lg-12 col-sm-12">
<div class="error-messages">
<div id="success">
<i class="far fa-check-circle"></i>Thank you, your message has been sent.
</div>
<div id="error">
<i class="far fa-times-circle"></i>Error occurred while sending email. Please try again later.
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
The code gives me this page on my website
but like I said, I cannot seem to get the send message button to actually send the message to my personal email. I just keep getting my error message from the HTML code 'Error occurred while sending email. Please try again later.'. If anyone has any ideas on how to go about fixing this it would be a big help!