/** * Dispatch actions to take according to current bounce level */ public function dispatch() { $this->findEmail(); // If couldn't find the original email we cannot do anything if (!$this->email) { Tx_Newsletter_Tools::log("Bounced email found but cannot find corresponding record in database. Skipped.", 1); return; } if ($this->bounceLevel != self::NEWSLETTER_NOT_A_BOUNCE) { if ($this->recipientList) { $this->recipientList->registerBounce($this->email->getRecipientAddress(), $this->bounceLevel); } $this->email->setBounceTime(new DateTime()); $emailRepository = $this->objectManager->get('Tx_Newsletter_Domain_Repository_EmailRepository'); $emailRepository->updateNow($this->email); } Tx_Newsletter_Tools::log("Bounced email found with bounce level " . $this->bounceLevel); }
/** * Method that accually runs the spool * * @global \TYPO3\CMS\Core\Database\DatabaseConnection $TYPO3_DB * @param resource SQL-resultset from a select from tx_newsletter_domain_model_email * @return void */ private static function runSpool($rs) { global $TYPO3_DB; $emailSentCount = 0; $mailers = array(); $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Extbase_Object_ObjectManager'); $newsletterRepository = $objectManager->get('Tx_Newsletter_Domain_Repository_NewsletterRepository'); $emailRepository = $objectManager->get('Tx_Newsletter_Domain_Repository_EmailRepository'); $oldNewsletterUid = null; while (list($newsletterUid, $emailUid) = $TYPO3_DB->sql_fetch_row($rs)) { /* For the page, this way we can support multiple pages in one spool session */ if ($newsletterUid != $oldNewsletterUid) { $oldNewsletterUid = $newsletterUid; $mailers = array(); $newsletter = $newsletterRepository->findByUid($newsletterUid); } // Define the language of email $email = $emailRepository->findByUid($emailUid); $recipientData = $email->getRecipientData(); $L = $recipientData['L']; // Was a language with this page defined, if not create one if (!is_object($mailers[$L])) { $mailers[$L] =& Tx_Newsletter_Tools::getConfiguredMailer($newsletter, $L); } // Mark it as started sending $email->setBeginTime(new DateTime()); $emailRepository->updateNow($email); // Send the email $mailers[$L]->send($email); // Mark it as sent already $email->setEndTime(new DateTime()); $emailRepository->updateNow($email); $emailSentCount++; } // Log numbers to syslog Tx_Newsletter_Tools::log("Sent {$emailSentCount} emails"); }