What I'm trying to do is this: I have a button that if clicked email will be sent to all customer in db that has email.
public function Email()
{
$ind_connect=$this->OpenDB();
$sql=mysql_query("SELECT `E-mail` FROM `orders`");
$num_rows=mysql_num_rows($sql);
$text ="Hi, How are you ?";
if($num_rows>0)
{
while($row = mysql_fetch_array($sql))
{
if(isset($row['E-mail']))
{
$tpl = file_get_contents("mail.eml");
$mail=$tpl;
$mail=strtr($mail,array(
"{TO}" =>$row['E-mail'],
"{TEXT}" =>$text,
));
list($head,$body) = preg_split("/?
?
/s",$mail,2);
echo "$head <br> $body <br>";
mail("","",$body,$head);
echo "<br>";
}
}
That's on the html file
Send Emails To Customers
<br><br><button name='SendEmail' button type='submit'>Click Here</button>
and this is calling to the func
if(isset($_POST['SendEmail']))
$db->Email();