<?
$itemid = base64_decode($_GET["itemid"]);

require_once("../include/mimemail.inc.php");

$mail = new MIMEMAIL("HTML");
$mail->senderName = $_POST["subject"];
$mail->senderMail = "mail-no-reply@easy-light.com";
$mail->subject = $_POST["subject"];  
$msg = $_POST["msg"];
$msg = str_replace('"','',$msg);
$msg = stripslashes($msg);


$mail->body = $msg;
$file1=$_FILES['file1'];
if ($file1['tmp_name']!="") 
	{
 $ct1=explode(".",$file1['name']);
			$last1=$ct1[count($ct1)-1];
			$name1="file1$max_id.$last1";
copy($file1['tmp_name'],"upload/$name1");
$mail->attachments[] = "upload/$name1";
	}
$mail->create(); 
$ssql="select * from efe_subsc order by idefe_subsc ASC";
$squery =mysql_query($ssql) or die ($ssql);
$snum_rows = mysql_num_rows($squery);
$si=0;
$fi=0;
while($srow = mysql_fetch_array($squery)) {

$mail->send($srow["subsc_email"]);

if($mail){
mysql_query("UPDATE efe_subsc SET subsc_last='".time()."' WHERE idefe_subsc = '".$srow["idefe_subsc"]."'");
}else{
$fi++;
}
$si++;}
Jsalert("Mail sent to ".$si." members already! (".$fi." Failed )");
Gotourl("index.php?option=mailsc");

?>