Help with PHP mail notification using if statement

I have a little script I prepared for a friend and myself to work around our email at our job. We use our work email for work and our personal emails for personal communications. However, we are not able to constantly check our personal email, nor do we care to keep it open, and installing anything to a work computer is out of the question. So I decided to write a PHP mail script that uses a simple form. I want it to send the email to the recipient (which is chosen via dropdown menu) and then if the recipient is (insert variable here for email addy) then do send alert email to this email address (insert variable here for alert1 email addy) or else send an alert email to (insert variable here for alert2 email addy) here instead.

<meta http-equiv="refresh" content="3;URL=http://www.domain.com/personalmail/main.php">
<?php
$emto = $_POST['emto'];
$emfrom = $_POST['emfrom'];
$emsubject = $_POST['emsubject'];
$embody = $_POST['embody'];
$adminem = $_POST['adminem'];
$coadminem = $_POST['coadminem'];
$headers = $_POST['[email protected]'];
$alert1 = $_POST["[email protected]"];
$alert2 = $_POST["[email protected]"];

$status = "OK";
$msg="";
//error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR);
if (!stristr($em,"@") OR !stristr($em,".")) {
$msg="Your email address is not correct<BR>";
$status= "NOTOK";}   

if($status=="OK"){// echo $query;
$headers="";
$headers4="[email protected]"; 
$headers.="Reply-to: $headers4n";
$headers .= "From: $headers4n";
$headers .= "Errors-to: $headers4n";
$headers = "Content-Type: text/html; charset=iso-8859-1n".$headers;
mail("$emto","To $emto - PersonalMail v1.0","

<html>
	<head>
		<title>PersonalMail</title>
	</head>

	<body bgcolor='#ffffff' leftmargin='0' marginheight='0' marginwidth='0' topmargin='0'>
		<div align='center'>
			<table width='692' border='0' cellspacing='0' cellpadding='5'>
				<tr>
					<td>
						<div align='center'>
							<img src='http://www.domain.com/images/topbanner.gif' height='60' width='468' border='0' /></div>
					</td>
				</tr>
				<tr>
					<td><font size='2' face='Verdana, Arial, Helvetica, sans-serif'><strong>To:</strong> $emto<br />
							<strong>From:</strong> $emfrom<br />
						</font>
						<hr />
						<font size='2' face='Verdana, Arial, Helvetica, sans-serif'><strong>Subject:</strong> $emsubject<br />
							<br />
						</font></td>
				</tr>
				<tr>
					<td align='left' valign='top'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'>$embody</font></td>
				</tr>
				<tr>
					<td align='center' valign='top'><font size='1' face='Verdana, Arial, Helvetica, sans-serif'><sub>copyright?2008 PersonalMail Inc. All Rights Reserved</sub></font></td>
				</tr>
			</table>
		</div>
		<p align='center'></p>
	</body>

</html>
<BR><BR> <BR> Reply: <a href='http://www.domain.com/personalmail/'>Click Here</a> <br>PersonalMail by <a href='http://www.domain.com/personalmail'>PersonalMail Inc.</a>
<br>  $dtl","$headers");
echo "<center>Thank you! <br><br> Your email was sent to $emto. </center>";
}

Any tips, tricks, suggestions, or assistance to steer me in the right direction is greatly appreciated. I tried looking all over the web for help but this is a very difficult thing to search for using a search engine, even though I am sure someone somewhere has the exact tutorial I need for this. Thanks in advance! :D

So far I have this working, but not sure if it is the best answer… Any suggestions? :-?

<meta http-equiv="refresh" content="3;URL=http://www.domain.com/Personalmail/main.php">
<?php
$emto = $_POST['emto'];
$emfrom = $_POST['emfrom'];
$emsubject = $_POST['emsubject'];
$embody = $_POST['embody'];
$headers = $_POST['[email protected]'];
$admin = $_POST['admin']; // users email sent via hidden field on form
$coadmin = $_POST['coadmin']; // users email sent via hidden field on form
$alertbanner = $_POST['http://www.domain.com/personalmail/images/noseyman-banner.gif'];
$emailbanner = $_POST['http://www.domain.com/personalmail/images/topbanner.gif'];

$status = "OK";
$msg="";
//error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR);
if (!stristr($emto,"@") OR !stristr($emto,".")) {
$msg="Your email address is not correct<BR>";
$status= "NOTOK";}   

if($status=="OK"){// echo $query;
$headers="";
$headers4="[email protected]"; 
$headers.="Reply-to: $headers4n";
$headers .= "From: $headers4n";
$headers .= "Errors-to: $headers4n";
$headers = "Content-Type: text/html; charset=iso-8859-1n".$headers;
mail("$emto","To $emto - PersonalMail v1.0","

<html>
	<head>
		<title>PersonalMail v1.0</title>
	</head>

	<body bgcolor='#ffffff' leftmargin='0' marginheight='0' marginwidth='0' topmargin='0'>
		<div align='center'>
			<table width='692' border='0' cellspacing='0' cellpadding='5'>
				<tr>
					<td>
						<div align='center'>
							<img src='$emailbanner' height='60' width='468' border='0' /></div>
					</td>
				</tr>
				<tr>
					<td><font size='2' face='Verdana, Arial, Helvetica, sans-serif'><strong>To:</strong> $emto<br />
							<strong>From:</strong> $emfrom<br />
						</font>
						<hr />
						<font size='2' face='Verdana, Arial, Helvetica, sans-serif'><strong>Subject:</strong> $emsubject<br />
							<br />
						</font></td>
				</tr>
				<tr>
					<td align='left' valign='top'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'>$embody</font></td>
				</tr>
				<tr>
					<td align='center' valign='top'><font size='1' face='Verdana, Arial, Helvetica, sans-serif'><sub>copyright?2008 PersonalMail Inc. All Rights Reserved</sub></font></td>
				</tr>
			</table>
		</div>
		<p align='center'></p>
	</body>

</html>
<BR> Reply: <a href='http://www.domain.com/Personalmail/'>Click Here</a> <br><br><br><sub>PersonalMail v1.0 by <a href='http://www.domain.com/'>PersonalMail Inc.</a></sub>
<br>  $dtl","$headers");
echo "<center>Thank you! <br><br> Your email was sent to $emto. </center>";
}
if($emto=="[email protected]"){// echo $query;
$headers="";
$headers4="[email protected]"; 
$headers.="Reply-to: $headers4n";
$headers .= "From: $headers4n";
$headers .= "Errors-to: $headers4n";
$headers = "Content-Type: text/html; charset=iso-8859-1n".$headers;
mail("$admin","ALERT - PersonalMail v1.0","

<html>

	<head>
		<title>PersonalMail ALERT!</title>
	</head>
	<body bgcolor='#ffffff'>
	<center><img src='$emailbanner' height='60' width='468' border='0' /></center><br>
		<p align='center'><font size='6' face='Verdana, Arial, Helvetica, sans-serif'><strong>Admin, You've Got Mail!</strong></font></p>
	</body>

</html>
<br>  $dtl","$headers");
echo "<center><b>Alert Status </b><br><br> Alert notice sent to Admin... </center>";
}else{// echo $query;
$headers="";
$headers4="[email protected]"; 
$headers.="Reply-to: $headers4n";
$headers .= "From: $headers4n";
$headers .= "Errors-to: $headers4n";
$headers = "Content-Type: text/html; charset=iso-8859-1n".$headers;
mail("$coadmin","ALERT - PersonalMail v1.0","

<html>

	<head>
		<title>PersonalMail ALERT!</title>
	</head>
	<body bgcolor='#ffffff'>
	<center><img src='$emailbanner' height='60' width='468' border='0' /></center>
		<p align='center'><font size='6' face='Verdana, Arial, Helvetica, sans-serif'><strong>CoAdmin, You've Got Mail!</strong></font></p>
	</body>

</html>
<br>  $dtl","$headers");
echo "<center><b>Alert Status </b><br><br> Alert notice sent to CoAdmin... </center>";
}
?>
Sponsor our Newsletter | Privacy Policy | Terms of Service