logEmail() public static method

public static logEmail ( Mail $mail ) : Log
$mail Pimcore\Mail
return Pimcore\Model\Tool\Email\Log
Example #1
0
 /**
  * Sends this email using the given transport or with the settings from "Settings" -> "System" -> "Email Settings"
  *
  * IMPORTANT: If the debug mode is enabled in "Settings" -> "System" -> "Debug" all emails will be sent to the
  * debug email addresses that are given in "Settings" -> "System" -> "Email Settings" -> "Debug email addresses"
  *
  * set DefaultTransport or the internal mail function if no
  * default transport had been set.
  *
  * @param  \Zend_Mail_Transport_Abstract $transport
  * @return \Pimcore\Mail Provides fluent interface
  */
 public function send($transport = null)
 {
     // filter email addresses
     $blockedAddresses = array();
     foreach ($this->getRecipients() as $recipient) {
         if (Model\Tool\Email\Blacklist::getByAddress($recipient)) {
             $blockedAddresses[] = $recipient;
         }
     }
     if (!empty($blockedAddresses)) {
         foreach ($blockedAddresses as $blockedAddress) {
             foreach (["To", "Cc", "Bcc"] as $type) {
                 $tmp = $this->_headers[$type];
                 foreach ($tmp as $key => &$value) {
                     if (strpos($value, $blockedAddress) !== false) {
                         unset($this->_headers[$type][$key]);
                         unset($this->_recipients[$value]);
                     }
                 }
             }
         }
     }
     $this->setSubject($this->getSubjectRendered());
     $bodyHtmlRendered = $this->getBodyHtmlRendered();
     if ($bodyHtmlRendered) {
         $this->setBodyHtml($bodyHtmlRendered);
     }
     $bodyTextRendered = $this->getBodyTextRendered();
     if ($bodyTextRendered) {
         $this->setBodyText($bodyTextRendered);
     }
     if ($this->ignoreDebugMode == false) {
         $this->checkDebugMode();
     }
     $result = parent::send($transport);
     if ($this->loggingIsEnabled()) {
         try {
             MailHelper::logEmail($this);
         } catch (\Exception $e) {
             \Logger::emerg("Couldn't log Email");
         }
     }
     return $result;
 }