<?php
if (isset($_POST["send"])) {
  $to = $_POST["to"];
  $subject = $_POST["subject"];
  $message = $_POST["message"];
  $headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
  $headers = "From: your@email-address.com\r\n";
  if (mail($to, $subject, $message, $headers)) {
     echo "SUCCESS";
  } else {
     echo "ERROR";
  }
}
?>
This is my php code, I have a HTML form and $to, $subject, $message is the input fields of the form, the $_POST["send"] is the button through which I want to send emails after clicking that button
 
     
    