codeigniter — PHP Mail Function ожидает и не работает с циклом foreach

Я пытаюсь отправить почту всем пользователям, у которых нет созданных отчетов в течение одного месяца, а также пытаюсь отправить почту этим пользователям с помощью цикла foreach и с функцией mail, когда я обновляю одно за другим, то отправляет почту одно за другим, затем работает. Я хочу отправить почту всем этим пользователям за один раз.

        $from = "xxx@xxx.com";
$subject = "";
$headers = "";
$inc = 0;
foreach($query->result_array() as $row)
{
$inc++;
$to = $row['us_email'];
$to_date = $row['report_date'];
if($to_date != "0000-00-00")
{
$subject = "Hello! (Reports Are Not Created).";

//begin of HTML message
$message = "1 month above you should create reports.";
}
else if($to_date == "0000-00-00")
{
$subject = "Hello! (Generate Reports).";

//begin of HTML message
$message ="generate reports to get more.";
}
$headers  = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers .= "To: User <".$to.">, Admin <".$from.">" . "\r\n";
$headers .= "From: Complete Online Marketing <".$from.">" . "\r\n";
$headers .= "Reply-To: Recipient Name <".$from.">";
$headers .= "Cc: [email]".$from."[/email]" . "\r\n";
$headers .= "Bcc: [email]".$from."[/email]" . "\r\n";// now lets send the email.
if(mail($to, $subject, $message, $headers))
{
echo $inc.") ".$row['us_firstname']." ".$row['us_lastname']." - Sending Success...\n";
$ins = array('report_mail'=>'0');
$this->db->update('se_user', $ins, array('us_id' => $row['us_id']));
}
else
{
echo $inc.") ".$row['us_firstname']." ".$row['us_lastname']." - Sending Fail...\n";
}
}

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector