<HTML><BODY onload="document.MyForm.Password.focus();document.MyForm.reset()">


<!-- 
Sending email. This is a simple email form.
HTMl emails, emails with attachments, forwarding emails, etc, will 
be covered later.

Here is the header of the PHP mail function:

bool mail ( string to, string subject, string message [, string 
additional_headers [, string additional_parameters]] )

The mail function is not recommended for large emails. Another way of 
sending email in PHP will be covered later.
-->

<?php


if (isset($_POST['submitted'])) // If the form is submitted
{
	$errors = array();
        $password = stripslashes(trim($_POST['Password']));
        if ($password == "fenton")
        {
                $from = stripslashes(trim($_POST['From']));
                $email = trim($_POST['Email']);
                //echo "[$from] $email <BR>";
                $to = trim($_POST['To']);
                $cc = trim($_POST['Cc']);
                $subject = stripslashes(trim($_POST['Subject']));
                $body = stripslashes(trim($_POST['Body']));
                $headers = "From: $from <$email>\r\n";
		//$headers = $headers."To: $to\r\n";
		if (!empty($cc))
	                $headers = $headers."CC: $cc\r\n";
		if (empty($email))
			$errors[] = "You have to enter your email address.";
		if (empty($to))
                        $errors[] = "You have to enter the email address of the recipient.";
		if (empty($errors)) // send the email
		{
	               mail($to,$subject,$body, $headers);
        	        echo "<P align=center>Your email has been sent.<P>\n";
		}
		else //display the errors
		{
			echo "<h1 align=center>ERROR</h1><center>\n";
			foreach ($errors as $e)
				echo $e, "<P>\n";
			echo "</center>\n";
		}
        }
	else
		echo "<P align=center>Wrong Password<P>\n";
}

else //display the form
{

	echo <<< Begin
	
	<TABLE WIDTH=80% ALIGN=center><TR><TD>
	<fieldset>
	<legend><B>
	Please fill out this form and submit it.
	</B></legend>
	<CENTER>

	<FORM ACTION="{$_SERVER['PHP_SELF']}" METHOD="POST" NAME="MyForm">

	<B>Password:</B>
	<INPUT NAME="Password" SIZE=30 type="password">
	<P>

	<B>From:</B>
	<INPUT NAME="From" SIZE=30>
	<P>

	<B>Your Email:</B>
	<INPUT NAME="Email" SIZE=30>
	<P>

	<B>To:</B>
	<INPUT NAME="To" SIZE=30>
	<P>

	<B>CC:</B>
	<INPUT NAME="Cc" SIZE=30>
	<P>

	<B>Subject:</B>
	<INPUT NAME="Subject" SIZE=30>
	<P>

	<INPUT type="hidden" name="submitted" value="TRUE">

	<TEXTAREA NAME="Body" ROWS=8 COLS=30 WRAP="virtual"></TEXTAREA>

	<CENTER><INPUT TYPE="submit" VALUE="SUBMIT"></CENTER> 
	<INPUT TYPE="reset" VALUE="CLEAR">

	</FORM></CENTER>
	</fieldset>
	</TD></TR></TABLE>

Begin;
}

?>
</BODY></HTML>
