<?php
include "chkuser.php";
include "includefilemng.php"; 
set_time_limit(0);
$site_main_path = "http://www.my-webprojects.com/herons-walk/";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Control Panel </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="ssi.css" rel="stylesheet" type="text/css">
<script src="includenp/functions.js"></script>
<script language="javascript">

function IsEmpty(aTextField)
{
   if ((aTextField.length==0) || (aTextField==null))
   {
      return true;
   }
   else
    { 
		return false;
	}
}	
function validateForm()
{

if(IsEmpty(document.form1.subject.value))
{	
	 errMsg = errMsg + "Please enter subject\n";
	 document.form1.subject.focus();
	 document.form1.subject.select();
	 errCount = errCount +1;
}


if(IsEmpty(document.form1.message.value))
{	
	 errMsg = errMsg + "Please enter mail\n";
	 document.form1.message.focus();
	 document.form1.message.select();
	 errCount = errCount +1;
}


if(errCount > 0)
{
	alert (errMsg);
	return false;
}
}
</script>

</head>
<body>
<table width="98%" border="0" cellspacing="0" cellpadding="2" align="center">
  <tr>
    <td width="1%"  bgcolor="#C9C9C9"></td>
	<td width="98%"><?php include_once "top.php";?></td>
	<td width="1%"  bgcolor="#C9C9C9"></td>
  </tr>
  <tr>
   <td width="1%"  bgcolor="#C9C9C9"></td>
    <td width="98%"><table width="100%"  border="0" cellpadding="0" cellspacing="0" class="centertable">
      <tr>
        <td><table width="80%"  border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="59%" height="50"></td>
            <td width="41%"></td>
          </tr>
          <tr>
            <td colspan="2">
			
            </td>
          </tr>
          <tr>
            <td colspan="2">
              <table width="100%"  border="0" cellpadding="2" cellspacing="0">
              
                  <tr>
                    <td width="100%" align="center">
		
				<TABLE class=table cellSpacing=3 cellPadding=3 width="98%" align=center border=0>
                      
						 
		
                   
                    <TR valign="top" class="trbg">
                      <TD colspan="7" align=center><?php
include "conn.php";   
//$groupid = $_POST['groupname'];
$mail_subject = $_POST['subject'];
$mailtype = $_POST['mailtype'];

//if text type mail
if($mailtype == "text")
{
	$mail_body = $_POST['message'];
	$mail_body = $mail_body . "\n"; 
	
  $headers="MIME-Verson:1.0\n";
  $headers = $headers . "Content-Type: text/html;charset=iso-8859-1\n";
  $headers = $headers . "Content-Transfer-Encoding: 8bit\n";
  $headers = $headers . "From: info@herons-walk.com";
  $headers =$headers. "X-Priority: 3\n";
  $headers =$headers. "X-MSMail-Priority: Normal\n";
  $headers =$headers. "X-Mailer: PHP\n";
}
//HTML type mail
else
{
$contents = stripslashes($_POST['txtContent']);
$contents = $contents ; 

  //$file = fopen("../newsletter_template/template.html",'rb');
  //$data = fread($file,filesize("../newsletter_template/template.html"));
 // fclose($file);
 $data ='';
  $mail_body = $contents . "\n";  	

  

  $headers="MIME-Verson:1.0\n";
  $headers = $headers . "Content-Type: text/html;charset=iso-8859-1\n";
  $headers = $headers . "Content-Transfer-Encoding: 8bit\n";
  $headers = $headers . "From: info@herons-walk.com";
  //$headers =$headers. "Message-ID: <" . md5(uniqid(time())) . "@virtualgroup.co.in>";
 
  $headers =$headers. "X-Priority: 3\n";
  $headers =$headers. "X-MSMail-Priority: Normal\n";
  $headers =$headers. "X-Mailer: PHP\n";



  
}

//send mails
$sqld = "SELECT * FROM subscribedusers ";
$resultd = mysql_query($sqld,$eclipse); 
$i = 0;
	while($rowd = mysql_fetch_object($resultd))
	{
		 $mail_to = $rowd->email;
		echo mail($mail_to,$mail_subject,$mail_body,$headers);
		$i = $i + 1;
	}
?>
<?php echo $i; ?><span class="titleheading"> Mails Sent...</span></TD>
                    </TR>
                    <TR valign="top" class="trbg">
                      <TD colspan="7" align=center>&nbsp;</TD>
                    </TR>
                    <TR valign="top" class="trbg">
                      <TD colspan="7" align=center>&nbsp;</TD>
                    </TR>
                    <TR valign="top" class="trbg">
                      <TD colspan="7" align=center><a href="htmlmail.php" class="bigblueTxt"></a></TD>
                      </TR>
                </TABLE>
				
				
			</td>
                  </tr>
           
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
    <td width="1%"  bgcolor="#C9C9C9"></td>
  </tr>
  <tr>
    <td  bgcolor="#C9C9C9" width="1%"></td>
	<td><?php include_once "footer.php";?></td>
	<td width="1%"  bgcolor="#C9C9C9"></td>
  </tr>
</table>
</body>
</html>
