<?php
// check the user has input a correct address
if(ereg("^(.+)@(.+)\\.(.+)$",$to))
{
}else{
echo("You must supply a valid (TO) address<br>");
echo("<script>alert(\"Error:Click Here To Go Back\");history.go(-1)</script>");
exit;
}
if(ereg("^(.+)@(.+)\\.(.+)$",$from))
{
}else{
echo("You must supply a valid (FROM) address<br>");
echo("<script>alert(\"Error:Click To Here Go Back\");history.go(-1)</script>");
exit;
}
// Removes html tags and whitespace from input data
$to =strip_tags(trim($to));
$subject =strip_tags(trim($subject));
$body =strip_tags(trim($body));
$from =strip_tags(trim($from));
// formats the headers section DO NOT ALTER OR MAKE ANY CHANGES
$headers ="Mime-Version: 1.0\r\nContent-Type:text/plain charset=\"ISO-8859-1\"\r\n";
$headers .="Content-Transfer-Encoding: 7bit\r\n";
$headers .="X-Priority: 3\r\n";
$headers .="X-PHP-Mail-Priority: Normal\r\n";
$headers .="X-Mime-OLE: Produced by MS MimeOLE v5.00.3000.100\r\n";
$headers .="X-Mailer: PHP Mail generated by:PHPMailer v1.0\r\n";
$headers .="From: PHP Mailer on $SERVER_NAME <$from>\r\n";
$headers .="Reply-to: $from\r\n";
// Appends the copyright notice to the bottom of the message
// DO NOT ALTER OR MAKE ANY CHANGES
$message .="\n";
$message .="\n-------------------------------------\n";
$message .="Generated by: PHP Mailer v1.0\n";
$message .="Copyright 2001 TELEMATICS SOFTWARE\n";
$message .="All Rights Reserved\n";
$message .="For Your Free Copy Go To:\n";
$message .="http://www.hosted.f2s.com/php/freescripts/index.php\n";
$message .="==================================\n";
// formats the input and sends the email
@$send=mail($to,$subject,$message,$headers);
// prints success or failure to the user
if($send==1){
echo("<html><head><title>SUCCESS...Email Sent</title></head><body>");
echo("<center><h2>Success....</h2><br><p>Your
email has been sent<br>");
echo("Thank You for using PHP Mailer v1.0<br>");
echo("Click here to send another email<br>");
echo("<a href=\"form.php\">PHPMAILER</a></p></center>");
echo("</body></html>");
}else{
echo("<html><head><title>FAILURE...Email Not Sent</title></head><body>");
echo("<center><h2>Sorry....</h2><br><p>There
appears to have been a problem<br>");
echo("in processing your email<br>Please try again later...<br>");
echo("<a href=\"form.php\">PHPMAILER</a><br>");
echo("Thank You for using PHP Mailer v1.0</p></center>");
echo("</body></html>");
}
// finally everything OK, exit the script
exit();
?>