We may earn a small commission from affiliate links and paid advertisements. Terms
<?php
// this is our handler of the form from above.
// localize the vars
$to = $_POST['to'];
$from = $_POST['from'];
$subject = $_POST['subject'];
$body = $_POST['body'];
// get headers
$header   = "From: ".$from ."\n";
$header  .= "Reply-To: ".$from."\r\n";
//check to make sure it went out
$sendcheck = mail($to, $subject, stripslashes($body), $header);
if($sendcheck)
{
echo "<p>Thank You!</p><p>Your mail has been sent.</p>";
}
else
echo "<h3>Error!</h3><p>Your email was not sent. </p>";
exit();
?> Â Â
<div>
<form action='<?=$PHP_SELF;?>' method='post'>
TO: <input type='text' name='to'> <br />
FROM: <input type='text' name='from'> <br />
SUBJECT: <input type='text' name='subject'><br />
BODY: <textarea name='body'></textarea><br />
</form>
</div>