<?php
require_once('../config/config.php');
require_once(CLASS_DIR.'dbClass.php');
$obj = new DBClass();
$obj2 = new DBClass();

$sql = "SELECT * FROM ".TBL_EMAIL." WHERE id = '".$_GET['id']."'";
$rs = $obj->executeQry($sql,$link);
$row = $obj->fetchrow();

$message = "Dear Sir, <br><br>Have a nice day <br><br><b>Date ".date("d-m-Y")."</b> <br>";

$message  .= html_entity_decode(stripslashes($row['message']));

$message  .= "<br><br><strong>Thanks and Regards</strong><br><br><strong>Shrinetra Infotech</strong><br>62, Sch. No. 114, Part 1<br>Near ICICI Bank ATM,<br>Indore, (M.P) 452010<br><br><strong>Phone : </strong> 0731-2012323<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+91-9993299974-78 (sales)<br><strong>Fax : </strong> 0731-4032323<br><strong>Email Id:</strong> shrinetrainfotech@gmail.com<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;info@coalbazaar.com<br><strong>Website:</strong><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;www.coalbazaar.com<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;www.coalmandi.com<br>";
			
			$sql2 = "SELECT * FROM news_subscribr";
			$rs2 = $obj2->executeQry($sql2,$link);
			while($row2 = $obj2->fetchrow()) {  
						
				$to        	= 	$row2['email'];
				$subject	=	$row['subject'];
				$headers  = 'MIME-Version: 1.0' . "\r\n";
				$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";				
				$headers .= "From: admin@coalbazaar.com \r\n";
				$sended=@mail($to, $subject, $message, $headers);				
			}	
				if($sended!='')
				{
					$status = 0;
					$sqll = "UPDATE ".TBL_EMAIL." SET status = '".trim($status)."' WHERE id = '".$_GET['id']."'";
					$rs2 = $obj->executeQry($sqll,$link);
					if($rs2){
					@header('Location: send-email.php?msg=send');
					exit;
					}
				}
				else {
					@header('Location: send-email.php?msg=fail');
					exit;
				}
?>