Ejemplo n.º 1
0
 /**
  * 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);
 }
 /**
  * Sends an email to the address configured in extension settings when a recipient unsubscribe
  * @param Tx_Newsletter_Domain_Model_Newsletter $newsletter
  * @param Tx_Newsletter_Domain_Model_RecipientList $recipientList
  * @param Tx_Newsletter_Domain_Model_Email $email
  * @return void
  */
 protected function notifyUnsubscribe($newsletter, $recipientList, Tx_Newsletter_Domain_Model_Email $email)
 {
     $notificationEmail = Tx_Newsletter_Tools::confParam('notification_email');
     // Use the page-owner as user
     if ($notificationEmail == 'user') {
         $rs = $GLOBALS['TYPO3_DB']->sql_query("SELECT email\n\t\t\tFROM be_users\n\t\t\tLEFT JOIN pages ON be_users.uid = pages.perms_userid\n\t\t\tWHERE pages.uid = " . $newsletter->getPid());
         list($notificationEmail) = $GLOBALS['TYPO3_DB']->sql_fetch_row($rs);
     }
     // If cannot find valid email, don't send any notification
     if (!\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($notificationEmail)) {
         return;
     }
     // Build email texts
     $baseUrl = 'http://' . $newsletter->getDomain();
     $urlRecipient = $baseUrl . '/typo3/alt_doc.php?&edit[tx_newsletter_domain_model_email][' . $email->getUid() . ']=edit';
     $urlRecipientList = $baseUrl . '/typo3/alt_doc.php?&edit[tx_newsletter_domain_model_recipientlist][' . $recipientList->getUid() . ']=edit';
     $urlNewsletter = $baseUrl . '/typo3/alt_doc.php?&edit[tx_newsletter_domain_model_newsletter][' . $newsletter->getUid() . ']=edit';
     $subject = Tx_Extbase_Utility_Localization::translate('unsubscribe_notification_subject', 'newsletter');
     $body = Tx_Extbase_Utility_Localization::translate('unsubscribe_notification_body', 'newsletter', array($email->getRecipientAddress(), $urlRecipient, $recipientList->getTitle(), $urlRecipientList, $newsletter->getTitle(), $urlNewsletter));
     // Actually sends email
     $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
     $message->setTo($notificationEmail)->setFrom(array($newsletter->getSenderEmail() => $newsletter->getSenderName()))->setSubject($subject)->setBody($body, 'text/html');
     $message->send();
 }
Ejemplo n.º 3
0
 /**
  * Raw send method. This does not replace markers, or reset the mail afterwards.
  *
  * @interal
  * @param   array      Record with receivers information as name => value pairs.
  * @param   array      Array with extra headers to apply to mails as name => value pairs.
  * @return   void
  */
 private function raw_send(Tx_Newsletter_Domain_Model_Email $email)
 {
     $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
     $message->setTo($email->getRecipientAddress())->setFrom(array($this->senderEmail => $this->senderName))->setSubject($this->title);
     if ($this->bounceAddress) {
         $message->setReturnPath($this->bounceAddress);
     }
     foreach ($this->attachments as $attachment) {
         $message->attach($attachment);
     }
     // Specify message-id for bounce identification
     $msgId = $message->getHeaders()->get('Message-ID');
     $msgId->setId($email->getAuthCode() . '@' . $this->newsletter->getDomain());
     // Build plaintext
     $plain = $this->getPlain();
     $recipientData = $email->getRecipientData();
     if ($recipientData['plain_only']) {
         $message->setBody($plain, 'text/plain');
     } else {
         // Attach inline files and replace markers used for URL
         foreach ($this->attachmentsEmbedded as $marker => $attachment) {
             $embeddedSrc = $message->embed($attachment);
             $plain = str_replace($marker, $embeddedSrc, $plain);
             $this->html = str_replace($marker, $embeddedSrc, $this->html);
         }
         $message->setBody($this->html, 'text/html');
         $message->addPart($plain, 'text/plain');
     }
     $message->send();
 }
Ejemplo n.º 4
0
 /**
  * @test
  */
 public function setNewsletterForTx_Newsletter_Domain_Model_NewsletterSetsNewsletter()
 {
     $dummyObject = new Tx_Newsletter_Domain_Model_Newsletter();
     $this->fixture->setNewsletter($dummyObject);
     $this->assertSame($dummyObject, $this->fixture->getNewsletter());
 }