protected function setDocumentSettings()
{
$document = $this->getDocument();
if ($document instanceof Model\Document\Email) {
if (!$this->recipientsCleared) {
$to = $document->getToAsArray();
if (!empty($to)) {
$this->addTo($to);
}
$cc = $document->getCcAsArray();
if (!empty($cc)) {
$this->addCc($cc);
}
$bcc = $document->getBccAsArray();
if (!empty($bcc)) {
$this->addBcc($bcc);
}
}
}
if ($document instanceof Model\Document\Email || $document instanceof Model\Document\Newsletter) {
//if more than one "from" email address is defined -> we set the first one
$fromArray = $document->getFromAsArray();
if (!empty($fromArray)) {
list($from) = $fromArray;
if ($from) {
$this->clearFrom();
$fromAddress = $from;
$fromName = null;
if (preg_match("/(.*)<(.*)>/", $from, $matches)) {
$fromAddress = trim($matches[2]);
$fromName = trim($matches[1]);
}
$this->setFrom($fromAddress, $fromName);
}
}
}
return $this;
}