<?php

require_once("_head.php");

mkheader("mailing!", "#eee");

?>

  <body>

    <!-- ======================================================= -->
    <?php

    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        mail(
            $_POST['toaddr'],
            $_POST['subject'],
            $_POST['message'],
            "From: {$_SERVER['PHP_SELF']} <php@localhost>"
        );
        ?><p>Sent!</p><p><a href="<?php echo $_SERVER['PHP_SELF']; ?>">clear this</a></p><?php

    } else {
        ?>

        <p>Send an email to somebody!</p>

        <form name="send_email" action="" method="POST">
          <label class="block" for="toaddr">To:</label>
          <input type="text" id="toaddr" name="toaddr" />

          <label class="block" for="subject">Subject:</label>
          <input type="text" id="subject" name="subject" />

          <label class="block" for="message">Message:</label>
          <textarea name="message" id="message" rows="10" cols="80"></textarea>
  
          <input class="block" type="submit" name="submit" value="Send" />
        </form>

        <?php
    }

    ?>

  </body>
</html>
