
<?
	error_reporting(0);
?><?php
/*
	Filename : newsletter.php
	
	Date : 16-07-2005
	Copyright ItechBids
	All rights Reserved
*/
?>
<style type="text/css">
<!--
.style1 {
	color: #666666;
	font-weight: bold;
}
.style3 {color: #666666; font-size: 11px; font-family:Arial, Helvetica, sans-serif}
-->
</style>
<table width="75%" class="ft" align="center">
  <tr class="ct" height="25"> 
    <td height="27" colspan="2">News Letter </td>
  </tr><?php 
   $cansend = $_POST["cansend"];
if(($cansend==1))
	{       
	        $qst_date=date("Y-m-d");
			$status="notification";
	        $adminidres=mysql_query("select * from member_details where user_name='admin'");
			$adminid=mysql_fetch_array($adminidres);
	        $from_id=$adminid[user_id];
			$alres=mysql_query("select * from member_details where email_enable_status='Yes'");
			while($alrow=mysql_fetch_array($alres))
			{
			$to_id=$alrow['user_id'];
			$mailTo=$alrow['email'];
			$mailfrom = $_POST["txtFrom"];
			$mailsubject = $_POST['txtSubject'];
			$headers  = "MIME-Version: 1.0\r\n";
			$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
			$headers .= "From: ". $mailfrom."\r\n";
			$mailbody= $_POST["txtMessage"];
            $ins_sql="insert into askseller(from_id,date,question,answer,to_id,status) values('$from_id','$qst_date','$mailbody','$mailsubject','$to_id','$status')";
			$ins_qry=mysql_query($ins_sql);
            $mail=mail($mailTo,$mailsubject ,$mailbody,$headers);
			}
			   		  if($mail)
				{
					$statusmail = "Mail Send Successfully to all users";
				}
				else
				{
					$statusmail =  "Problem in sending your Email...";
				}
		}
?>
              <?
                if ($statusmail!="")
		{
                echo "<tr><td colspan=2 align=center><font color=#FF0000>".$statusmail."</font></tr>";
                }
	      ?>
              <tr>
	<td valign="top" colspan=2><b></tr>
	<form name=form1 action="<?php $_SERVER['PHP_SELF']; ?>" method=post onsubmit="this.cansend.value=1;return true;">
	<tr >
              <td width="50%">From 
              <td width="50%">
<?php
    $admin_sql="select * from genaralsettings where set_id=3";
    $get_res=mysql_query($admin_sql);
    $get_row=mysql_fetch_array($get_res);
    $adminmail=$get_row['set_value'];
?>
<input type="text" class="bluetext"name="txtFrom" value="<?=$adminmail; ?>" class="txt">
</td></tr>

	<tr >
              <td>Subject
<td>
<input type="text" class="bluetext"class="txt" name="txtSubject">
</td>
</tr>
	<tr >
              <td valign=top>Message
<td><textarea name=txtMessage rows=5 cols=25></textarea>
</td></tr>
	<tr >
              <td height="28" colspan=2 align=center>
<input type=submit Value=" Send " ></td></tr>
	<input type=hidden name=cansend value=0>
	</form>
</table>
