/**
  * {@inheritDoc}
  */
 public function getFromAddress()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getFromAddress', array());
     return parent::getFromAddress();
 }
Esempio n. 2
0
 /**
  * @param Email $email
  * @param bool  $allowBcc            Honor BCC if set in email
  * @param array $slots               Slots configured in theme
  * @param array $assetAttachments    Assets to send
  * @param bool  $ignoreTrackingPixel Do not append tracking pixel HTML
  */
 public function setEmail(Email $email, $allowBcc = true, $slots = array(), $assetAttachments = array(), $ignoreTrackingPixel = false)
 {
     $this->email = $email;
     $subject = $email->getSubject();
     // Convert short codes to emoji
     $subject = EmojiHelper::toEmoji($subject, 'short');
     // Set message settings from the email
     $this->setSubject($subject);
     $fromEmail = $email->getFromAddress();
     $fromName = $email->getFromName();
     if (!empty($fromEmail) && !empty($fromEmail)) {
         $this->setFrom($fromEmail, $fromName);
     } else {
         if (!empty($fromEmail)) {
             $this->setFrom($fromEmail, $this->from);
         } else {
             if (!empty($fromName)) {
                 $this->setFrom(key($this->from), $fromName);
             }
         }
     }
     $replyTo = $email->getReplyToAddress();
     if (!empty($replyTo)) {
         $this->setReplyTo($replyTo);
     }
     if ($allowBcc) {
         $bccAddress = $email->getBccAddress();
         if (!empty($bccAddress)) {
             $this->addBcc($bccAddress);
         }
     }
     if ($plainText = $email->getPlainText()) {
         $this->setPlainText($plainText);
     }
     $template = $email->getTemplate();
     if (!empty($template)) {
         if (empty($slots)) {
             $template = $email->getTemplate();
             $slots = $this->factory->getTheme($template)->getSlots('email');
         }
         if (isset($slots[$template])) {
             $slots = $slots[$template];
         }
         $customHtml = $this->setTemplate('MauticEmailBundle::public.html.php', array('slots' => $slots, 'content' => $email->getContent(), 'email' => $email, 'template' => $template), true);
     } else {
         // Tak on the tracking pixel token
         $customHtml = $email->getCustomHtml();
     }
     // Convert short codes to emoji
     $customHtml = EmojiHelper::toEmoji($customHtml, 'short');
     $this->setBody($customHtml, 'text/html', null, $ignoreTrackingPixel);
     // Reset attachments
     $this->assets = $this->attachedAssets = array();
     if (empty($assetAttachments)) {
         if ($assets = $email->getAssetAttachments()) {
             foreach ($assets as $asset) {
                 $this->attachAsset($asset);
             }
         }
     } else {
         foreach ($assetAttachments as $asset) {
             $this->attachAsset($asset);
         }
     }
 }
Esempio n. 3
0
 /**
  * @param Email $email
  * @param bool  $allowBcc            Honor BCC if set in email
  * @param array $slots               Slots configured in theme
  * @param array $assetAttachments    Assets to send
  * @param bool  $ignoreTrackingPixel Do not append tracking pixel HTML
  */
 public function setEmail(Email $email, $allowBcc = true, $slots = [], $assetAttachments = [], $ignoreTrackingPixel = false)
 {
     $this->email = $email;
     $subject = $email->getSubject();
     // Convert short codes to emoji
     $subject = EmojiHelper::toEmoji($subject, 'short');
     // Set message settings from the email
     $this->setSubject($subject);
     $fromEmail = $email->getFromAddress();
     $fromName = $email->getFromName();
     if (!empty($fromEmail) && !empty($fromEmail)) {
         $this->setFrom($fromEmail, $fromName);
     } elseif (!empty($fromEmail)) {
         $this->setFrom($fromEmail, $this->from);
     } elseif (!empty($fromName)) {
         $this->setFrom(key($this->from), $fromName);
     }
     $replyTo = $email->getReplyToAddress();
     if (!empty($replyTo)) {
         $this->setReplyTo($replyTo);
     }
     if ($allowBcc) {
         $bccAddress = $email->getBccAddress();
         if (!empty($bccAddress)) {
             $this->addBcc($bccAddress);
         }
     }
     if ($plainText = $email->getPlainText()) {
         $this->setPlainText($plainText);
     }
     $BCcontent = $email->getContent();
     $customHtml = $email->getCustomHtml();
     // Process emails created by Mautic v1
     if (empty($customHtml) && !empty($BCcontent)) {
         $template = $email->getTemplate();
         if (empty($slots)) {
             $template = $email->getTemplate();
             $slots = $this->factory->getTheme($template)->getSlots('email');
         }
         if (isset($slots[$template])) {
             $slots = $slots[$template];
         }
         $this->processSlots($slots, $email);
         $logicalName = $this->factory->getHelper('theme')->checkForTwigTemplate(':' . $template . ':email.html.php');
         $customHtml = $this->setTemplate($logicalName, ['slots' => $slots, 'content' => $email->getContent(), 'email' => $email, 'template' => $template], true);
     }
     // Convert short codes to emoji
     $customHtml = EmojiHelper::toEmoji($customHtml, 'short');
     $this->setBody($customHtml, 'text/html', null, $ignoreTrackingPixel);
     // Reset attachments
     $this->assets = $this->attachedAssets = [];
     if (empty($assetAttachments)) {
         if ($assets = $email->getAssetAttachments()) {
             foreach ($assets as $asset) {
                 $this->attachAsset($asset);
             }
         }
     } else {
         foreach ($assetAttachments as $asset) {
             $this->attachAsset($asset);
         }
     }
 }