function sendSchedule($d, $showHTML, $receivers, $list, &$message, &$max, $tags = null) { static $countEmails = 0; $mailing = $d['mailing']; $h = ''; $xf = new xonfig(); if (empty($mailing)) { $message = _ACA_NO_MAILING_ENTERED; return false; } elseif (empty($receivers)) { $message = _ACA_NO_ADDRESS_ENTERED; return false; } elseif (empty($list)) { $message = _ACA_NO_LIST_ENTERED; return false; } else { $message = ''; } $mailingId = $mailing->id; $issue_nb = $mailing->issue_nb; $subject = $mailing->subject; $content = $mailing->htmlcontent; $textonly = $mailing->textonly; $fromname = $mailing->fromname; $fromemail = $mailing->fromemail; $images = $mailing->images; $listId = $list->id; $html = $list->html; $layout = $list->layout; $totalsofar = number_format(0, 4, ',', ''); $nbPause = 0; $tags['issuenb'] = $issue_nb; if (ini_get('safe_mode')) { } else { @set_time_limit(60 * $GLOBALS[ACA . 'script_timeout']); } ignore_user_abort(true); ### create the mail $mail = acajoom_mail::getMailer($mailing); ### create content acajoom_mail::getContent($images, $layout, $content, $textonly); $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; $html_sent = 0; $text_sent = 0; $size = sizeof($receivers); $log_detailed = "\r\n" . "\r\n" . '*** ' . strftime(_DATE_FORMAT_LC) . ' ***' . "\r\n"; foreach ($receivers as $receiver) { $tags['user_id'] = $receiver->user_id; if ($html && intval($receiver->receive_html) == 1) { $mail->IsHTML(true); $ashtml = 1; $Altbody = acajoom_mail::replaceTags($textonly, $receiver, $list, $mailingId, 0, $tags); $mail->AltBody = acajoom_mail::safe_utf8_encode($Altbody, $mail->CharSet); $html_sent++; $mail->Body = acajoom_mail::replaceTags($content, $receiver, $list, $mailingId, $ashtml, $tags); } else { $mail->IsHTML(false); $mail->AltBody = ''; $ashtml = 0; $text_sent++; $mail->Body = acajoom_mail::replaceTags($textonly, $receiver, $list, $mailingId, $ashtml, $tags); // if we are in TEXT Mode, Why do we add embedded images??? if (!empty($images)) { foreach ($images as $image) { $img = explode('|', $image); $attrib = explode("/", $img[0]); $path = $GLOBALS['mosConfig_absolute_path'] . '/images/stories/'; if (count($img) == 1) { $imageName = $img[0]; } else { $imageName = $attrib[count($attrib) - 1]; for ($index = 0; $index < sizeof($attrib) - 1; $index++) { $path .= $attrib[$index] . '/'; } } $mail->AddAttachment($path . $imageName); } } } $tname = explode(" ", $receiver->name); $firstname = $tname[0]; $mail->AddAddress($receiver->email, $receiver->name); $sujetReplaced = str_replace('[NAME]', $receiver->name, $subject); $sujetReplaced = str_replace('[FIRSTNAME]', $firstname, $sujetReplaced); if (class_exists('auto')) { auto::tags($sujetReplaced, $tags); } $mail->Subject = $sujetReplaced; $mailssend = $mail->Send(); $countEmails++; if ($countEmails >= $GLOBALS[ACA . 'cron_max_emails']) { $max = true; } if ($mail->error_count > 0) { static $info = false; if (!$info and acajoom::checkPermissions('admin')) { echo '<br/>Mailer Error : ' . $mail->ErrorInfo; $info = true; } $log_detailed .= '[' . $mailingId . '] ' . $subject . ' : ' . $receiver->email . ' -> ' . _ACA_MESSAGE_NOT . "\r\n" . _ACA_MAILER_ERROR . ': ' . $mail->ErrorInfo . "\r\n"; if ($html && intval($receiver->receive_html) == 1) { $html_sent--; } else { $text_sent--; } } else { $log_detailed .= '[' . $mailingId . '] ' . $subject . ' : ' . $receiver->email . ' -> ' . _ACA_MESSAGE_SENT_SUCCESSFULLY . "\r\n"; if ($GLOBALS[ACA . 'enable_statistics'] == 1 and $GLOBALS[ACA . 'statistics_per_subscriber'] == 1) { xmailing::insertStats($mailingId, $receiver->id, $ashtml); } $d['qids'] = array(); $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__); if ($d['listype'] == '2') { $d['qids'][0] = queue::whatQID($mailingId, $receiver->id, $d['listype']); $erro->ck = auto::updateAutoresponderSent($d); $erro->Eck(__LINE__, '8137', $d); } elseif ($d['listype'] == '1' || $d['listype'] == '7') { $d['qids'][0] = queue::whatQID($mailingId, $receiver->id, $d['listype']); $erro->ck = queue::deleteQueues($d['qids']); $erro->Eck(__LINE__, '8127', $d); } } $mail->ClearAddresses(); } if ($GLOBALS[ACA . 'enable_statistics'] == 1) { xmailing::updateStatsGlobal($mailingId, $html_sent, $text_sent, false); } $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; if ($totalsofar > 0) { $totaltime = $totalsofar; $totalstr = strval($totaltime); } else { $totaltime = number_format($endtime - $starttime - $nbPause * $GLOBALS[ACA . 'pause_time'], 4, ',', ''); $totalstr = strval($totaltime); } if ($GLOBALS[ACA . 'send_data'] == 1) { acajoom_mail::sendReport($fromemail, $totalstr, $html_sent, $text_sent); } $xf->plus('totalmailingsent' . $list->list_type, $html_sent + $text_sent); $xf->plus('totalmailingsent0', $html_sent + $text_sent); $log_simple = 'Time to send: ' . $totalstr . ' ' . _ACA_SECONDS . "\r\n" . 'Number of subscribers: ' . ($text_sent + $html_sent) . "\r\n" . 'HTML format: ' . $html_sent . "\r\n" . 'Text format: ' . $text_sent . "\r\n"; $log_detailed = $log_simple . 'Details: ' . "\r\n" . $log_detailed . "\r\n"; if (class_exists('lisType')) { acajoom_mail::writeLogs($list, $log_simple, $log_detailed); } if ($d['listype'] == '2') { echo '<br/>' . _ACA_QUEUE_AUTO_PROCESSED; } elseif ($d['listype'] == '1') { echo '<br/>' . _ACA_QUEUE_NEWS_PROCESSED; } if ($html_sent + $text_sent > 0) { return true; } else { $message = xmailing::M('no', _ACA_NO_MAILING_SENT); return false; } }