コード例 #1
0
 /**
  * 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();
 }
コード例 #2
0
 /**
  * @test
  */
 public function setSenderEmailForStringSetsSenderEmail()
 {
     $this->fixture->setSenderEmail('Conceived at T3CON10');
     $this->assertSame('Conceived at T3CON10', $this->fixture->getSenderEmail());
 }
コード例 #3
0
 public function setNewsletter(Tx_Newsletter_Domain_Model_Newsletter $newsletter, $language = null)
 {
     $domain = $newsletter->getDomain();
     // When sending newsletter via scheduler (so via CLI mode) realurl cannot guess
     // the domain name by himself, so we help him by filling HTTP_HOST variable
     $_SERVER['HTTP_HOST'] = $domain;
     $_SERVER['SCRIPT_NAME'] = '/index.php';
     $this->siteUrl = "http://{$domain}/";
     $this->linksCache = array();
     $this->newsletter = $newsletter;
     $this->homeUrl = $this->siteUrl . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('newsletter');
     $this->senderName = $newsletter->getSenderName();
     $this->senderEmail = $newsletter->getSenderEmail();
     $bounceAccount = $newsletter->getBounceAccount();
     $this->bounceAddress = $bounceAccount ? $bounceAccount->getEmail() : '';
     // Build html
     $validatedContent = $newsletter->getValidatedContent($language);
     if (count($validatedContent['errors'])) {
         throw new Exception('The newsletter HTML content does not validate. The sending is aborted. See errors: ' . serialize($validatedContent['errors']));
     }
     $this->setHtml($validatedContent['content']);
     // Build title from HTML source (we cannot use $newsletter->getTitle(), because it is NOT localized)
     $this->setTitle($validatedContent['content']);
     // Attaching files
     $files = $newsletter->getAttachments();
     foreach ($files as $file) {
         if (trim($file) != '') {
             $filename = PATH_site . "uploads/tx_newsletter/{$file}";
             $this->attachments[] = Swift_Attachment::fromPath($filename);
         }
     }
 }