public function addMimeHeaders($options = array())
{
if (empty($options['headers'])) {
$headers = new Horde_Mime_Headers();
} else {
$headers = $options['headers'];
$headers->removeHeader('Content-Disposition');
$headers->removeHeader('Content-Transfer-Encoding');
}
/* Add the mandatory Content-Type header. */
$ct = $this->_headers['content-type'];
$headers->addHeaderOb($ct);
/* Add the language(s), if set. (RFC 3282 [2]) */
if ($hdr = $this->_headers['content-language']) {
$headers->addHeaderOb($hdr);
}
/* Get the description, if any. */
if ($hdr = $this->_headers['content-description']) {
$headers->addHeaderOb($hdr);
}
/* Set the duration, if it exists. (RFC 3803) */
if ($hdr = $this->_headers['content-duration']) {
$headers->addHeaderOb($hdr);
}
/* Per RFC 2046[4], this MUST appear in the base message headers. */
if ($this->_status & self::STATUS_BASEPART) {
$headers->addHeaderOb(Horde_Mime_Headers_MimeVersion::create());
}
/* message/* parts require no additional header information. */
if ($ct->ptype === 'message') {
return $headers;
}
/* RFC 2183 [2] indicates that default is no requested disposition -
* the receiving MUA is responsible for display choice. */
$cd = $this->_headers['content-disposition'];
if (!$cd->isDefault()) {
$headers->addHeaderOb($cd);
}
/* Add transfer encoding information. RFC 2045 [6.1] indicates that
* default is 7bit. No need to send the header in this case. */
$cte = new Horde_Mime_Headers_ContentTransferEncoding(null, $this->_getTransferEncoding(empty($options['encode']) ? null : $options['encode']));
if (!$cte->isDefault()) {
$headers->addHeaderOb($cte);
}
/* Add content ID information. */
if ($hdr = $this->_headers['content-id']) {
$headers->addHeaderOb($hdr);
}
return $headers;
}