I am trying to send multiple emails to respective emails address from the database using the mail function.
$sql = mysqli_query($con,"select emails from email_test");
while($row = mysqli_fetch_array($sql)){
$to = $row['emails'];
$subject ="testing bulkmail";
$header = "from:noreply";
$message ="Testing mail funtion.";
$mail = mail($to, $subject, $message, $header);
if ($mail) {
$output.= "<div class='alert alert-success alert-dismissable fade in'><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>E-mail send succesfully on registered E-mail Addresses</div>";
} else {
$output.= '<div class="alert alert-dismissable fade in"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Error! please Try After Sometime</div>';
}
}
if(isset($output)){
echo $output;
}
Right now I have 4 emails address in the emails
column and all email address is different from each other when I run the script the email only received on 2 email address only. what I trying to do is send emails to all email Address that are present in the database. I am looking a best or better way to implement this script, any help and suggestion is highly apprecheated.