Doc = $Doc; $this->DBObj = SiteMap::getObj('BroadcastEmail/BroadcastEmail.php'); $this->send(); exit; } function getEmailObject() { $this->DBObj->initFromDB(); $data = $this->DBObj->getData(); if (empty($data)) { die('ERROR Email data is empty (id=' . $this->DBObj->id . ')'); } $emailObject = $this->DBObj->prepareEmail($data, &$this->Doc); return $emailObject; } function send() { $ids_email = $this->DBObj->getEmailId4Send(); foreach ($ids_email as $id_email) { $this->DBObj->id = $id_email; $this->sendEmail(); } $ids_email = $this->DBObj->getEmailId4Send(); if (!empty($ids_email)) { die('CONTINUE ANOTHER EMAILS'); } die('DONE ALL'); } function sendEmail() { if (!($emailObject = $this->getEmailObject())) { die('ERROR Invalid Email Object'); } $emails = $this->DBObj->getRecipientEmails($this->limitRecipients); $startTime = time(); $sorter = $this->DBObj->getRecipientsSorter(); foreach ($emails as $id_member => $email) { if (false === $emailObject->send(array($email))) { //usleep(10000); //if (false) { $this->DBObj->logError($this->DBObj->id, $id_member, $sorter); } else { $this->DBObj->logSuccess($this->DBObj->id, $id_member, $sorter); } $sorter++; if ($startTime + $this->lifeTime < time()) { break; } } //$recipientsCount = $this->DBObj->getWaitingRecipientsCount(); // if ($recipientsCount) { // die('CONTINUE ' . $recipientsCount); // } //die('DONE'); } }