/**
* @throws \Exception
* @throws \Zend_Mail_Exception
*/
protected function checkDebugMode()
{
if (\Pimcore::inDebugMode()) {
if (empty(self::$debugEmailAddresses)) {
throw new \Exception('No valid debug email address given in "Settings" -> "System" -> "Email Settings"');
}
if ($this->preventDebugInformationAppending != true) {
//adding the debug information to the html email
$html = $this->getBodyHtml();
if ($html instanceof \Zend_Mime_Part) {
$rawHtml = $html->getRawContent();
$debugInformation = MailHelper::getDebugInformation('html', $this);
$debugInformationStyling = MailHelper::getDebugInformationCssStyle();
$rawHtml = preg_replace("!(</\\s*body\\s*>)!is", "{$debugInformation}\\1", $rawHtml);
$rawHtml = preg_replace("!(<\\s*head\\s*>)!is", "\\1{$debugInformationStyling}", $rawHtml);
$this->setBodyHtml($rawHtml);
}
$text = $this->getBodyText();
if ($text instanceof \Zend_Mime_Part) {
$rawText = $text->getRawContent();
$debugInformation = MailHelper::getDebugInformation('text', $this);
$rawText .= $debugInformation;
$this->setBodyText($rawText);
}
//setting debug subject
$subject = $this->getSubject();
$this->clearSubject();
$this->setSubject('Debug email: ' . $subject);
}
$this->clearRecipients();
$this->addTo(self::$debugEmailAddresses);
}
}