本文整理汇总了PHP中Horde_Mime_Part::setType方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Mime_Part::setType方法的具体用法?PHP Horde_Mime_Part::setType怎么用?PHP Horde_Mime_Part::setType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Mime_Part
的用法示例。
在下文中一共展示了Horde_Mime_Part::setType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
private function load()
{
$headers = [];
$fetch_query = new \Horde_Imap_Client_Fetch_Query();
$fetch_query->bodyPart($this->attachmentId);
$fetch_query->mimeHeader($this->attachmentId);
$headers = array_merge($headers, ['importance', 'list-post', 'x-priority']);
$headers[] = 'content-type';
$fetch_query->headers('imp', $headers, ['cache' => true]);
// $list is an array of Horde_Imap_Client_Data_Fetch objects.
$ids = new \Horde_Imap_Client_Ids($this->messageId);
$headers = $this->conn->fetch($this->mailBox, $fetch_query, ['ids' => $ids]);
/** @var $fetch Horde_Imap_Client_Data_Fetch */
if (!isset($headers[$this->messageId])) {
throw new DoesNotExistException('Unable to load the attachment.');
}
$fetch = $headers[$this->messageId];
$mimeHeaders = $fetch->getMimeHeader($this->attachmentId, Horde_Imap_Client_Data_Fetch::HEADER_PARSE);
$this->mimePart = new \Horde_Mime_Part();
// To prevent potential problems with the SOP we serve all files with the
// MIME type "application/octet-stream"
$this->mimePart->setType('application/octet-stream');
// Serve all files with a content-disposition of "attachment" to prevent Cross-Site Scripting
$this->mimePart->setDisposition('attachment');
// Extract headers from part
$contentDisposition = $mimeHeaders->getValue('content-disposition', \Horde_Mime_Headers::VALUE_PARAMS);
if (!is_null($contentDisposition)) {
$vars = ['filename'];
foreach ($contentDisposition as $key => $val) {
if (in_array($key, $vars)) {
$this->mimePart->setDispositionParameter($key, $val);
}
}
} else {
$contentDisposition = $mimeHeaders->getValue('content-type', \Horde_Mime_Headers::VALUE_PARAMS);
$vars = ['name'];
foreach ($contentDisposition as $key => $val) {
if (in_array($key, $vars)) {
$this->mimePart->setContentTypeParameter($key, $val);
}
}
}
/* Content transfer encoding. */
if ($tmp = $mimeHeaders->getValue('content-transfer-encoding')) {
$this->mimePart->setTransferEncoding($tmp);
}
$body = $fetch->getBodyPart($this->attachmentId);
$this->mimePart->setContents($body);
}
示例2: verifyIdentity
/**
* Sends a message to an email address supposed to be added to the
* identity.
*
* A message is send to this address containing a time-sensitive link to
* confirm that the address really belongs to that user.
*
* @param integer $id The identity's ID.
* @param string $old_addr The old From: address.
*
* @throws Horde_Mime_Exception
*/
public function verifyIdentity($id, $old_addr)
{
global $injector, $notification, $registry;
$hash = strval(new Horde_Support_Randomid());
$pref = $this->_confirmEmail();
$pref[$hash] = $this->get($id);
$pref[$hash][self::EXPIRE] = time() + self::EXPIRE_SECS;
$this->_confirmEmail($pref);
$new_addr = $this->getValue($this->_prefnames['from_addr'], $id);
$confirm = Horde::url($registry->getServiceLink('emailconfirm')->add('h', $hash)->setRaw(true), true);
$message = sprintf(Horde_Core_Translation::t("You have requested to add the email address \"%s\" to the list of your personal email addresses.\n\nGo to the following link to confirm that this is really your address:\n%s\n\nIf you don't know what this message means, you can delete it."), $new_addr, $confirm);
$msg_headers = new Horde_Mime_Headers();
$msg_headers->addHeaderOb(Horde_Mime_Headers_MessageId::create());
$msg_headers->addHeaderOb(Horde_Mime_Headers_UserAgent::create());
$msg_headers->addHeaderOb(Horde_Mime_Headers_Date::create());
$msg_headers->addHeader('To', $new_addr);
$msg_headers->addHeader('From', $old_addr);
$msg_headers->addHeader('Subject', Horde_Core_Translation::t("Confirm new email address"));
$body = new Horde_Mime_Part();
$body->setType('text/plain');
$body->setContents(Horde_String::wrap($message, 76));
$body->setCharset('UTF-8');
$body->send($new_addr, $msg_headers, $injector->getInstance('Horde_Mail'));
$notification->push(sprintf(Horde_Core_Translation::t("A message has been sent to \"%s\" to verify that this is really your address. The new email address is activated as soon as you confirm this message."), $new_addr), 'horde.message');
}
示例3: _getEmbeddedMimeParts
/**
* If this MIME part can contain embedded MIME part(s), and those part(s)
* exist, return a representation of that data.
*
* @return mixed A Horde_Mime_Part object representing the embedded data.
* Returns null if no embedded MIME part(s) exist.
*/
protected function _getEmbeddedMimeParts()
{
/* Get the data from the attachment. */
try {
if (!($tnef = $this->getConfigParam('tnef'))) {
$tnef = Horde_Compress::factory('Tnef');
$this->setConfigParam('tnef', $tnef);
}
$tnefData = $tnef->decompress($this->_mimepart->getContents());
} catch (Horde_Compress_Exception $e) {
$tnefData = array();
}
if (!count($tnefData)) {
return null;
}
$mixed = new Horde_Mime_Part();
$mixed->setType('multipart/mixed');
reset($tnefData);
while (list(, $data) = each($tnefData)) {
$temp_part = new Horde_Mime_Part();
$temp_part->setName($data['name']);
$temp_part->setDescription($data['name']);
$temp_part->setContents($data['stream']);
/* Short-circuit MIME-type guessing for winmail.dat parts;
* we're showing enough entries for them already. */
$type = $data['type'] . '/' . $data['subtype'];
if (in_array($type, array('application/octet-stream', 'application/base64'))) {
$type = Horde_Mime_Magic::filenameToMIME($data['name']);
}
$temp_part->setType($type);
$mixed->addPart($temp_part);
}
return $mixed;
}
示例4: createMimePart
/**
* Generates a Horde_Mime_Part object, in accordance with RFC 3156, that
* contains a public key.
*
* @return Horde_Mime_Part Object that contains the armored public key.
*/
public function createMimePart()
{
$part = new Horde_Mime_Part();
$part->setType('application/pgp-keys');
$part->setHeaderCharset('UTF-8');
$part->setDescription(Horde_Pgp_Translation::t("PGP Public Key"));
$part->setContents(strval($this), array('encoding' => '7bit'));
return $part;
}
示例5: token
/**
* Renders a token into text matching the requested format.
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
$part = new Horde_Mime_Part();
$part->setContents($options['text']);
$part->setType('application/x-extension-' . $options['attr']['type']);
$viewer = Horde_Mime_Viewer::factory('Horde_Core_Mime_Viewer_Syntaxhighlighter', $part, array('registry' => $GLOBALS['registry']));
$data = $viewer->render('inline');
$data = reset($data);
return $data['data'];
}
示例6: testStructure
public function testStructure()
{
$this->assertInstanceOf('Horde_Mime_Part', $this->ob->getStructure());
$test = new Horde_Mime_Part();
$test->setType('image/foo');
$this->ob->setStructure($test);
$serialize_ob = unserialize(serialize($this->ob));
foreach (array($this->ob, $serialize_ob) as $val) {
$ret = $val->getStructure();
$this->assertInstanceOf('Horde_Mime_Part', $ret);
$this->assertEquals('image/foo', $ret->getType('image/foo'));
}
}
示例7: getMultipartMimeMessage
private function getMultipartMimeMessage($mime_type)
{
$envelope = new Horde_Mime_Part();
$envelope->setType('multipart/mixed');
$foo = new Horde_Mime_Part();
$foo->setType('foo/bar');
$envelope->addPart($foo);
$kolab = new Horde_Mime_Part();
$kolab->setType($mime_type);
$envelope->addPart($kolab);
$envelope->buildMimeIds();
return $envelope;
}
示例8: report
/**
*/
public function report(IMP_Contents $contents, $action)
{
global $injector, $registry;
$imp_compose = $injector->getInstance('IMP_Factory_Compose')->create();
switch ($this->_format) {
case 'redirect':
/* Send the message. */
try {
$imp_compose->redirectMessage($contents->getIndicesOb());
$imp_compose->sendRedirectMessage($this->_email, false);
return true;
} catch (IMP_Compose_Exception $e) {
$e->log();
}
break;
case 'digest':
default:
try {
$from_line = $injector->getInstance('IMP_Identity')->getFromLine();
} catch (Horde_Exception $e) {
$from_line = null;
}
/* Build the MIME structure. */
$mime = new Horde_Mime_Part();
$mime->setType('multipart/digest');
$rfc822 = new Horde_Mime_Part();
$rfc822->setType('message/rfc822');
$rfc822->setContents($contents->fullMessageText(array('stream' => true)));
$mime->addPart($rfc822);
$spam_headers = new Horde_Mime_Headers();
$spam_headers->addMessageIdHeader();
$spam_headers->addHeader('Date', date('r'));
$spam_headers->addHeader('To', $this->_email);
if (!is_null($from_line)) {
$spam_headers->addHeader('From', $from_line);
}
$spam_headers->addHeader('Subject', sprintf(_("%s report from %s"), $action == IMP_Spam::SPAM ? 'spam' : 'innocent', $registry->getAuth()));
/* Send the message. */
try {
$recip_list = $imp_compose->recipientList(array('to' => $this->_email));
$imp_compose->sendMessage($recip_list['list'], $spam_headers, $mime, 'UTF-8');
$rfc822->clearContents();
return true;
} catch (IMP_Compose_Exception $e) {
$e->log();
$rfc822->clearContents();
}
break;
}
return false;
}
示例9: testReplaceMime
public function testReplaceMime()
{
$fixture = file_get_contents(__DIR__ . '/fixtures/signed_attachment.eml');
$mime = new Horde_ActiveSync_Mime(Horde_Mime_Part::parseMessage($fixture));
foreach ($mime->contentTypeMap() as $id => $type) {
if ($mime->isAttachment($id, $type)) {
$part = new Horde_Mime_Part();
$part->setType('text/plain');
$part->setContents(sprintf('An attachment named %s was removed by Horde_ActiveSync_Test', $mime->getPart($id)->getName(true)));
$mime->removePart($id);
$mime->addPart($part);
}
}
$this->assertEquals(true, $mime->hasAttachments());
$this->assertEquals('An attachment named foxtrotjobs.png was removed by Horde_ActiveSync_Test', $mime->getPart('3')->getContents());
}
示例10: testBug10431
public function testBug10431()
{
$text = 'Das könnte zum Beispiel so aussehen, dass wir bei entsprechenden Anfragen diese an eine Kontaktperson bei Euch weiterleiten. Oder Ihr schnürt ein entsprechendes Paket, dass wir in unseren Angeboten mit anführen. Bei erfolgreicher Vermittlung bekämen wir eine Vermittlungsgebühr.
Wir ständen dann weiterhin für 3rd-Level-Support zur Verfügung, d.h. für alle Anfragen des Kunden bzgl. Horde, die nicht zum Tagesgeschäft gehören.';
$text = Horde_String::convertCharset($text, 'UTF-8', 'ISO-8859-1');
$textBody = new Horde_Mime_Part();
$textBody->setType('text/plain');
$textBody->setCharset('ISO-8859-1');
$flowed = new Horde_Text_Flowed($text, 'ISO-8859-1');
$flowed->setDelSp(true);
$textBody->setContents($flowed->toFlowed());
$flowed_txt = $textBody->toString(array('headers' => false));
$textBody2 = new Horde_Mime_Part();
$textBody2->setType('text/plain');
$textBody2->setCharset('ISO-8859-1');
$textBody2->setContents($flowed_txt, array('encoding' => 'quoted-printable'));
$flowed2 = new Horde_Text_Flowed($textBody2->getContents(), 'ISO-8859-1');
$flowed2->setMaxLength(0);
$flowed2->setDelSp(true);
$this->assertEquals($text, trim($flowed2->toFixed()));
}
示例11: stripPart
/**
* Strips one or all MIME parts out of a message.
*
* @param string $partid The MIME ID of the part to strip. All parts are
* stripped if null.
*
* @return IMP_Indices Returns the new indices object.
* @throws IMP_Exception
*/
public function stripPart($partid = null)
{
global $injector;
list($mbox, $uid) = $this->getSingle();
if (!$uid) {
return;
}
if ($mbox->readonly) {
throw new IMP_Exception(_("Cannot strip the part as the mailbox is read-only."));
}
$uidvalidity = $mbox->uidvalid;
$contents = $injector->getInstance('IMP_Factory_Contents')->create($this);
$message = $contents->getMIMEMessage();
$boundary = trim($message->getContentTypeParameter('boundary'), '"');
$url = new Horde_Imap_Client_Url();
$url->mailbox = $mbox;
$url->uid = $uid;
$url->uidvalidity = $uidvalidity;
$imp_imap = $mbox->imp_imap;
/* Always add the header to output. */
$url->section = 'HEADER';
$parts = array(array('t' => 'url', 'v' => strval($url)));
for ($id = 1;; ++$id) {
if (!($part = $message[$id])) {
break;
}
$parts[] = array('t' => 'text', 'v' => "\r\n--" . $boundary . "\r\n");
if ($id != 1 && is_null($partid) || $id == $partid) {
$newPart = new Horde_Mime_Part();
$newPart->setType('text/plain');
/* Need to make sure all text is in the correct charset. */
$newPart->setCharset('UTF-8');
$newPart->setContents(sprintf(_("[Part stripped: Original part type: %s, name: %s]"), $part->getType(), $contents->getPartName($part)));
$newPart->setDisposition('attachment');
$parts[] = array('t' => 'text', 'v' => $newPart->toString(array('canonical' => true, 'headers' => true, 'stream' => true)));
} else {
$url->section = $id . '.MIME';
$parts[] = array('t' => 'url', 'v' => strval($url));
$url->section = $id;
$parts[] = array('t' => 'url', 'v' => strval($url));
}
}
$parts[] = array('t' => 'text', 'v' => "\r\n--" . $boundary . "--\r\n");
/* Get the headers for the message. */
$query = new Horde_Imap_Client_Fetch_Query();
$query->imapDate();
$query->flags();
try {
$res = $imp_imap->fetch($mbox, $query, array('ids' => $imp_imap->getIdsOb($uid)))->first();
if (is_null($res)) {
throw new IMP_Imap_Exception();
}
$flags = $res->getFlags();
/* If in Virtual Inbox, we need to reset flag to unseen so that it
* appears again in the mailbox list. */
if ($mbox->vinbox) {
$flags = array_values(array_diff($flags, array(Horde_Imap_Client::FLAG_SEEN)));
}
$new_uid = $imp_imap->append($mbox, array(array('data' => $parts, 'flags' => $flags, 'internaldate' => $res->getImapDate())))->ids;
$new_uid = reset($new_uid);
} catch (IMP_Imap_Exception $e) {
throw new IMP_Exception(_("An error occured while attempting to strip the part."));
}
$this->delete(array('keeplog' => true, 'nuke' => true));
$indices_ob = $mbox->getIndicesOb($new_uid);
/* We need to replace the old UID(s) in the URL params. */
$vars = $injector->getInstance('Horde_Variables');
if (isset($vars->buid)) {
list(, $vars->buid) = $mbox->toBuids($indices_ob)->getSingle();
}
if (isset($vars->uid)) {
$vars->uid = $new_uid;
}
return $indices_ob;
}
示例12: vfsDisplayUrl
/**
* Returns a link to display and download a file from the VFS backend
* associated with this object.
*
* @param string $file The file name.
*
* @return string The HTML code of the generated link.
*/
public function vfsDisplayUrl($file)
{
global $registry;
$mime_part = new Horde_Mime_Part();
$mime_part->setType(Horde_Mime_Magic::extToMime($file['type']));
$viewer = $GLOBALS['injector']->getInstance('Horde_Core_Factory_MimeViewer')->create($mime_part);
// We can always download files.
$url_params = array('actionID' => 'download_file', 'file' => $file['name'], 'type' => $file['type'], 'source' => $this->driver->getName(), 'key' => $this->getValue('__key'));
$dl = Horde::link($registry->downloadUrl($file['name'], $url_params), $file['name']) . Horde_Themes_Image::tag('download.png', array('alt' => _("Download"))) . '</a>';
// Let's see if we can view this one, too.
if ($viewer && !$viewer instanceof Horde_Mime_Viewer_Default) {
$url = Horde::url('view.php')->add($url_params)->add('actionID', 'view_file');
$link = Horde::link($url, $file['name'], null, '_blank') . $file['name'] . '</a>';
} else {
$link = $file['name'];
}
return $link . ' ' . $dl;
}
示例13: armorToPart
/**
* Converts armored input into a Horde_Mime_Part object.
*
* @param mixed $input Armored input.
* @param array $opts Additional options:
* - charset: (string) Charset of the armored input.
*
* @return mixed Either null if no PGP data was found, or a
* Horde_Mime_Part object.
*/
public function armorToPart($input, array $opts = array())
{
$opts = array_merge(array('charset' => 'UTF-8'), $opts);
$armor = Horde_Pgp_Armor::create($input);
$new_part = new Horde_Mime_Part();
$new_part->setType('multipart/mixed');
foreach ($armor as $val) {
switch (get_class($val)) {
case 'Horde_Pgp_Element_Text':
$part = new Horde_Mime_Part();
$part->setType('text/plain');
$part->setCharset($opts['charset']);
$part->setContents($val->message[0]->data);
$new_part[] = $part;
break;
case 'Horde_Pgp_Element_PrivateKey':
case 'Horde_Pgp_Element_PublicKey':
$part = new Horde_Mime_Part();
$part->setType('application/pgp-keys');
$part->setContents(strval($val));
$new_part[] = $part;
break;
case 'Horde_Pgp_Element_Message':
// TODO: Message can also be text or signature
$part = $this->_encryptBase($val);
$part->setMetadata(self::PGP_ARMOR, true);
$part['2']->setMetadata(self::PGP_CHARSET, isset($val->headers['Charset']) ? $val->headers['Charset'] : 'UTF-8');
$new_part[] = $part;
break;
case 'Horde_Pgp_Element_SignedMessage':
$part = $this->_signPart($val->text, $val->signature);
$new_part[] = $part;
break;
}
}
return count($new_part->getParts()) ? $new_part : null;
}
示例14: saveObject
/**
* Save an object in this folder.
*
* @param array $object The array that holds the data of the object.
* @param int $data_version The format handler version.
* @param string $object_type The type of the kolab object.
* @param string $id The IMAP id of the old object if it
* existed before
* @param array $old_object The array that holds the current data of the
* object.
*
* @return boolean True on success.
*/
public function saveObject(&$object, $data_version, $object_type, $id = null, &$old_object = null)
{
// Select folder
$this->_driver->select($this->_path);
$new_headers = new Horde_Mime_Headers();
$new_headers->setEOL("\r\n");
$formats = $this->getFormats();
$handlers = array();
foreach ($formats as $type) {
$handlers[$type] =& Horde_Kolab_Format::factory($type, $object_type, $data_version);
if (is_a($handlers[$type], 'PEAR_Error')) {
if ($type == 'XML') {
return $handlers[$type];
}
Horde::log(sprintf('Loading format handler "%s" failed: %s', $type, $handlers[$type]->getMessage()), 'ERR');
continue;
}
}
if ($id != null) {
/** Update an existing kolab object */
if (!in_array($id, $this->_driver->getUids($this->_path))) {
return PEAR::raiseError(sprintf(Horde_Kolab_Storage_Translation::t("The message with ID %s does not exist. This probably means that the Kolab object has been modified by somebody else while you were editing it. Your edits have been lost."), $id));
}
/** Parse email and load Kolab format structure */
$result = $this->parseMessage($id, $handlers['XML']->getMimeType(), true, $formats);
if (is_a($result, 'PEAR_Error')) {
return $result;
}
list($old_message, $part_ids, $mime_message, $mime_headers) = $result;
if (is_a($old_message, 'PEAR_Error')) {
return $old_message;
}
if (isset($object['_attachments']) && isset($old_object['_attachments'])) {
$attachments = array_keys($object['_attachments']);
foreach (array_keys($old_object['_attachments']) as $attachment) {
if (!in_array($attachment, $attachments)) {
foreach ($mime_message->getParts() as $part) {
if ($part->getName() === $attachment) {
foreach (array_keys($mime_message->_parts) as $key) {
if ($mime_message->_parts[$key]->getMimeId() == $part->getMimeId()) {
unset($mime_message->_parts[$key]);
break;
}
}
$mime_message->_generateIdMap($mime_message->_parts);
}
}
}
}
}
$object = array_merge($old_object, $object);
if (isset($attachments)) {
foreach ($mime_message->getParts() as $part) {
$name = $part->getName();
foreach ($attachments as $attachment) {
if ($name === $attachment) {
$object['_attachments'][$attachment]['id'] = $part->getMimeId();
}
}
}
}
/** Copy email header */
if (!empty($mime_headers) && !$mime_headers === false) {
foreach ($mime_headers as $header => $value) {
$new_headers->addheader($header, $value);
}
}
} else {
$mime_message = $this->_prepareNewMessage($new_headers);
$mime_part_id = false;
}
if (isset($object['_attachments'])) {
$attachments = array_keys($object['_attachments']);
foreach ($attachments as $attachment) {
$data = $object['_attachments'][$attachment];
if (!isset($data['content']) && !isset($data['path'])) {
/**
* There no new content and no new path. Do not rewrite the
* attachment.
*/
continue;
}
$part = new Horde_Mime_Part();
$part->setType(isset($data['type']) ? $data['type'] : null);
$part->setContents(isset($data['content']) ? $data['content'] : file_get_contents($data['path']));
$part->setCharset('UTF-8');
$part->setTransferEncoding('quoted-printable');
//.........这里部分代码省略.........
示例15: generate
/**
* Generate the MDN according to the specifications listed in RFC
* 3798 [3].
*
* @param boolean $action Was this MDN type a result of a manual
* action on part of the user?
* @param boolean $sending Was this MDN sent as a result of a manual
* action on part of the user?
* @param string $type The type of action performed by the user.
* Per RFC 3798 [3.2.6.2] the following types are
* valid:
* - deleted
* - displayed
* @param string $name The name of the local server.
* @param Horde_Mail_Transport $mailer Mail transport object.
* @param array $opts Additional options:
* - charset: (string) Default charset.
* DEFAULT: NONE
* - from_addr: (string) From address.
* DEFAULT: NONE
* @param array $mod The list of modifications. Per RFC 3798
* [3.2.6.3] the following modifications are
* valid:
* - error
* @param array $err If $mod is 'error', the additional
* information to provide. Key is the type of
* modification, value is the text.
*/
public function generate($action, $sending, $type, $name, $mailer, array $opts = array(), array $mod = array(), array $err = array())
{
$opts = array_merge(array('charset' => null, 'from_addr' => null), $opts);
if (!($hdr = $this->_headers[self::MDN_HEADER])) {
throw new RuntimeException('Need at least one address to send MDN to.');
}
$to = $hdr->getAddressList(true);
$ua = Horde_Mime_Headers_UserAgent::create();
if ($orig_recip = $this->_headers['Original-Recipient']) {
$orig_recip = $orig_recip->value_single;
}
/* Set up the mail headers. */
$msg_headers = new Horde_Mime_Headers();
$msg_headers->addHeaderOb(Horde_Mime_Headers_MessageId::create());
$msg_headers->addHeaderOb($ua);
/* RFC 3834 [5.2] */
$msg_headers->addHeader('Auto-Submitted', 'auto-replied');
$msg_headers->addHeaderOb(Horde_Mime_Headers_Date::create());
if ($opts['from_addr']) {
$msg_headers->addHeader('From', $opts['from_addr']);
}
$msg_headers->addHeader('To', $to);
$msg_headers->addHeader('Subject', Horde_Mime_Translation::t("Disposition Notification"));
/* MDNs are a subtype of 'multipart/report'. */
$msg = new Horde_Mime_Part();
$msg->setType('multipart/report');
$msg->setContentTypeParameter('report-type', 'disposition-notification');
/* The first part is a human readable message. */
$part_one = new Horde_Mime_Part();
$part_one->setType('text/plain');
$part_one->setCharset($opts['charset']);
if ($type == 'displayed') {
$contents = sprintf(Horde_Mime_Translation::t("The message sent on %s to %s with subject \"%s\" has been displayed.\n\nThis is no guarantee that the message has been read or understood."), $this->_headers['Date'], $this->_headers['To'], $this->_headers['Subject']);
$flowed = new Horde_Text_Flowed($contents, $opts['charset']);
$flowed->setDelSp(true);
$part_one->setContentTypeParameter('format', 'flowed');
$part_one->setContentTypeParameter('DelSp', 'Yes');
$part_one->setContents($flowed->toFlowed());
}
// TODO: Messages for other notification types.
$msg[] = $part_one;
/* The second part is a machine-parseable description. */
$part_two = new Horde_Mime_Part();
$part_two->setType('message/disposition-notification');
$part_two_h = new Horde_Mime_Headers();
$part_two_h->addHeader('Reporting-UA', $name . '; ' . $ua);
if (!empty($orig_recip)) {
$part_two_h->addHeader('Original-Recipient', 'rfc822;' . $orig_recip);
}
if ($opts['from_addr']) {
$part_two_h->addHeader('Final-Recipient', 'rfc822;' . $opts['from_addr']);
}
if ($msg_id = $this->_headers['Message-ID']) {
$part_two_h->addHeader('Original-Message-ID', strval($msg_id));
}
/* Create the Disposition field now (RFC 3798 [3.2.6]). */
$dispo = ($action ? 'manual-action' : 'automatic-action') . '/' . ($sending ? 'MDN-sent-manually' : 'MDN-sent-automatically') . '; ' . $type;
if (!empty($mod)) {
$dispo .= '/' . implode(', ', $mod);
}
$part_two_h->addHeader('Disposition', $dispo);
if (in_array('error', $mod) && isset($err['error'])) {
$part_two_h->addHeader('Error', $err['error']);
}
$part_two->setContents(trim($part_two_h->toString()) . "\n");
$msg[] = $part_two;
/* The third part is the text of the original message. RFC 3798 [3]
* allows us to return only a portion of the entire message - this
* is left up to the user. */
$part_three = new Horde_Mime_Part();
$part_three->setType('message/rfc822');
$part_three_text = array(trim($this->_headers->toString()) . "\n");
//.........这里部分代码省略.........