Ejemplo n.º 1
0
 /**
  * Sets the newsletter
  *
  * @param Newsletter $newsletter
  * @param string $language
  * @throws \Exception
  */
 public function setNewsletter(Newsletter $newsletter, $language = null)
 {
     // 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'] = $newsletter->getDomain();
     $_SERVER['SCRIPT_NAME'] = '/index.php';
     $this->siteUrl = $newsletter->getBaseUrl() . '/';
     $this->linksCache = [];
     $this->newsletter = $newsletter;
     $this->homeUrl = $this->siteUrl . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('newsletter');
     $this->senderName = $newsletter->getSenderName();
     $this->senderEmail = $newsletter->getSenderEmail();
     $this->replytoName = $newsletter->getReplytoName();
     $this->replytoEmail = $newsletter->getReplytoEmail();
     $bounceAccount = $newsletter->getBounceAccount();
     $this->bounceAddress = $bounceAccount ? $bounceAccount->getEmail() : null;
     // 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);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * @test
  */
 public function getReplytoName()
 {
     $this->assertSame('John Connor', $this->subject->getReplytoName(), 'sould return globally configured default value');
     $this->subject->setReplytoName('My custom name');
     $this->assertSame('My custom name', $this->subject->getReplytoName(), 'sould return locally set value');
 }