I am trying to simulate an email behavior using a database. These are the codes i used for sending mail to one recipient. How do i send it to multiple recipients.
if($to=="" || $sub=="" || $msg=="")
{
$err= "<h3 style='color:red'>fill the related data first</h3>";
}
else
{
$d=mysqli_query($con,"SELECT * FROM userinfo where email='$to'");
$row=mysqli_num_rows($d);
if($row==1)
{
mysqli_query($con,"INSERT INTO usermail values('','$to','$id','$sub','$msg','$file',sysdate())");
$err= "<h3 style='color:blue'>Message sent...</h3>";
}
else
{
$sub=$sub."--"."msg failed";
mysqli_query($con,"INSERT INTO usermail values('','$id','$id','$sub','$msg','$file',sysdate())");
$err= "<h3 style='color:red'>Message failed because reciever not found...</h3>";
}
}
If i got your problem:
Lets say $to="abc@x.com;zdf@x.com";
else
{
$toStack = explode(';',$to);
foreach($toStack as $to){
$d=mysqli_query($con,"SELECT * FROM userinfo where email='$to'");
/** and the rest of your code from the else block **/
}
}
have a nice day..