/** */ public function __get($name) { switch ($name) { case 'reply_to': $name = 'reply-to'; // Fall-through // Fall-through case 'bcc': case 'cc': case 'from': case 'sender': case 'to': if (($ob = $this->_data->getOb($name)) !== null) { return $ob; } if (in_array($name, array('sender', 'reply-to'))) { return $this->from; } break; case 'date': if (($val = $this->_data->getValue($name)) !== null) { return new Horde_Imap_Client_DateTime($val); } break; case 'in_reply_to': case 'message_id': case 'subject': if (($val = $this->_data->getValue($name)) !== null) { return $val; } break; } // Default values. switch ($name) { case 'bcc': case 'cc': case 'from': case 'to': return new Horde_Mail_Rfc822_List(); case 'date': return new Horde_Imap_Client_DateTime(); case 'in_reply_to': case 'message_id': case 'subject': return ''; } return null; }
/** * Sends this message. * * @param Mail $mailer A Mail object. * @param boolean $resend If true, the message id and date are re-used; * If false, they will be updated. * @param boolean $flowed Send message in flowed text format. * * @throws Horde_Mime_Exception */ public function send($mailer, $resend = false, $flowed = true) { /* Add mandatory headers if missing. */ $has_header = $this->_headers->getValue('Message-ID'); if (!$resend || !$has_header) { if ($has_header) { $this->_headers->removeHeader('Message-ID'); } $this->_headers->addMessageIdHeader(); } if (!$this->_headers->getValue('User-Agent')) { $this->_headers->addUserAgentHeader(); } $has_header = $this->_headers->getValue('Date'); if (!$resend || !$has_header) { if ($has_header) { $this->_headers->removeHeader('Date'); } $this->_headers->addHeader('Date', date('r')); } if (isset($this->_base)) { $basepart = $this->_base; } else { /* Send in flowed format. */ if ($flowed && !empty($this->_body)) { $flowed = new Horde_Text_Flowed($this->_body->getContents(), $this->_body->getCharset()); $flowed->setDelSp(true); $this->_body->setContentTypeParameter('format', 'flowed'); $this->_body->setContentTypeParameter('DelSp', 'Yes'); $this->_body->setContents($flowed->toFlowed()); } /* Build mime message. */ $body = new Horde_Mime_Part(); if (!empty($this->_body) && !empty($this->_htmlBody)) { $body->setType('multipart/alternative'); $this->_body->setDescription(Horde_Mime_Translation::t("Plaintext Version of Message")); $body->addPart($this->_body); $this->_htmlBody->setDescription(Horde_Mime_Translation::t("HTML Version of Message")); $body->addPart($this->_htmlBody); } elseif (!empty($this->_htmlBody)) { $body = $this->_htmlBody; } elseif (!empty($this->_body)) { $body = $this->_body; } if (count($this->_parts)) { $basepart = new Horde_Mime_Part(); $basepart->setType('multipart/mixed'); $basepart->isBasePart(true); if ($body) { $basepart->addPart($body); } foreach ($this->_parts as $mime_part) { $basepart->addPart($mime_part); } } else { $basepart = $body; $basepart->isBasePart(true); } } $basepart->setHeaderCharset($this->_charset); /* Build recipients. */ $recipients = clone $this->_recipients; foreach (array('to', 'cc') as $header) { $recipients->add($this->_headers->getOb($header)); } if ($this->_bcc) { $recipients->add($this->_bcc); } /* Trick Horde_Mime_Part into re-generating the message headers. */ $this->_headers->removeHeader('MIME-Version'); /* Send message. */ $recipients->unique(); $basepart->send($recipients->writeAddress(), $this->_headers, $mailer); /* Remember the basepart */ $this->_base = $basepart; }
/** * Determine the header information to display in the forward/reply. * * @param Horde_Mime_Headers $h The headers object for the message. * * @return string The header information for the original message. */ protected function _getMsgHeaders($h) { $tmp = array(); if ($ob = $h->getValue('date')) { $tmp[_("Date")] = $ob; } if ($ob = strval($h->getOb('from'))) { $tmp[_("From")] = $ob; } if ($ob = strval($h->getOb('reply-to'))) { $tmp[_("Reply-To")] = $ob; } if ($ob = $h->getValue('subject')) { $tmp[_("Subject")] = $ob; } if ($ob = strval($h->getOb('to'))) { $tmp[_("To")] = $ob; } if ($ob = strval($h->getOb('cc'))) { $tmp[_("Cc")] = $ob; } $text = ''; if (!empty($tmp)) { $max = max(array_map(array('Horde_String', 'length'), array_keys($tmp))) + 2; foreach ($tmp as $key => $val) { $text .= Horde_String::pad($key . ': ', $max, ' ', STR_PAD_LEFT) . $val . "\n"; } } return $text; }