Pimcore\Mail::sendWithoutRendering PHP Method

sendWithoutRendering() public method

see also comments of send() method
public sendWithoutRendering ( null $transport = null ) : Zend_Mail
$transport null
return Zend_Mail
    public function sendWithoutRendering($transport = null)
    {
        // filter email addresses
        $blockedAddresses = [];
        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]);
                        }
                    }
                }
            }
        }
        $result = parent::send($transport);
        if ($this->loggingIsEnabled()) {
            try {
                MailHelper::logEmail($this);
            } catch (\Exception $e) {
                Logger::emerg("Couldn't log Email");
            }
        }
        return $result;
    }

Usage Example

Beispiel #1
0
 /**
  * @param Mail $mail
  * @param SendingParamContainer $sendingContainer
  */
 public static function sendNewsletterDocumentBasedMail(Mail $mail, SendingParamContainer $sendingContainer)
 {
     $mailAddress = $sendingContainer->getEmail();
     if (!empty($mailAddress)) {
         $mail->setTo($mailAddress);
         $mail->sendWithoutRendering();
         Logger::info("Sent newsletter to: " . self::obfuscateEmail($mailAddress) . " [" . $mail->getDocument()->getId() . "]");
     } else {
         Logger::warn("No E-Mail Address given - cannot send mail. [" . $mail->getDocument()->getId() . "]");
     }
 }