<?php
  $sent = false;
  if (isset($_POST["submit"])) {
    $to = $_POST["useremail"];
    $subject = "Newsletter subscription";
    $message = "Congratulations! You have subscribed to our newsletter.";
    $headers = array("From" => "webmaster@example.com", "Reply-To" => "webmaster@example.com");
    $sent = mail($to, $subject, $message, $headers);
  }
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>PHP Document</title>
</head>
<body>
  <?php
    if ($sent) {
      echo "<div><p>Email Sent!</p></div>";
    }
  ?>
  <section>
    <form name="myform" method="post" action="contact.php">
      <input type="email" name="useremail">
      <input type="submit" name="submit">
    </form>
  </section>
</body>
</html>