I am trying to send a an HTML form entry via mail using PHP. I have tried but it is not working.
Below is my HTML code:
<form action="assets/php/consultationmail.php" method="post">
<div class="input-field">
<input type="text" name="name" placeholder="Full Name" required>
</div>
<div class="input-field">
<input type="email" name="email" placeholder="[email protected]" required>
</div>
<div class="input-field">
<input type="tel" name="Phone" placeholder="0245678910" required>
</div>
<div class="input-field">
<input type="textarea" name="message" placeholder="Message" required>
</div>
<div class=" input-field">
<button type="submit" value="submit" class="template-btn">Get Consultations
<i class="far fa-long-arrow-right"></i></button>
</div>
</form>
And here’s is the PHP Code I added
<?php
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$message=$_POST['message'];
$email_from='[email protected]';
$email_subject='New Consultation Request';
$email_body='A visitor has request for a consultation.<br>Details are below<br>Name:'.$name.'<br>Email:'.$email.'<br>Phone:'.$phone.'<br>Message:'.$message.'<br>';
$to='[email protected]';
$to=$to;
$subject=$email_subject;
$message=$email_body;
$headers='From:'.$email_from."\r\n".'Reply-To:'.$email."\r\n".'X-Mailer:PHP/'.phpversion();
mail($to,$subject,$message,$headers);
?>
What am I doing wrong, please?