本文整理汇总了PHP中Horde_Mime_Part::getEOL方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Mime_Part::getEOL方法的具体用法?PHP Horde_Mime_Part::getEOL怎么用?PHP Horde_Mime_Part::getEOL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Mime_Part
的用法示例。
在下文中一共展示了Horde_Mime_Part::getEOL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 Mail $mailer A Mail driver.
* @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.
*
* @throws Horde_Mime_Exception
*/
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);
$to = $this->getMdnReturnAddr();
$ua = $this->_headers->getUserAgent();
$orig_recip = $this->_headers->getValue('Original-Recipient');
if (!empty($orig_recip) && is_array($orig_recip)) {
$orig_recip = $orig_recip[0];
}
$msg_id = $this->_headers->getValue('Message-ID');
/* Create the Disposition field now (RFC 3798 [3.2.6]). */
$dispo = 'Disposition: ' . ($action ? 'manual-action' : 'automatic-action') . '/' . ($sending ? 'MDN-sent-manually' : 'MDN-sent-automatically') . '; ' . $type;
if (!empty($mod)) {
$dispo .= '/' . implode(', ', $mod);
}
/* Set up the mail headers. */
$msg_headers = new Horde_Mime_Headers();
$msg_headers->addMessageIdHeader();
$msg_headers->addUserAgentHeader($ua);
$msg_headers->addHeader('Date', date('r'));
if ($opts['from_addr']) {
$msg_headers->addHeader('From', $opts['from_addr']);
}
$msg_headers->addHeader('To', $this->getMdnReturnAddr());
$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->getValue('Date'), $this->_headers->getValue('To'), $this->_headers->getValue('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->addPart($part_one);
/* The second part is a machine-parseable description. */
$part_two = new Horde_Mime_Part();
$part_two->setType('message/disposition-notification');
$part_two_text = array('Reporting-UA: ' . $name . '; ' . $ua . "\n");
if (!empty($orig_recip)) {
$part_two_text[] = 'Original-Recipient: rfc822;' . $orig_recip . "\n";
}
if ($opts['from_addr']) {
$part_two_text[] = 'Final-Recipient: rfc822;' . $opts['from_addr'] . "\n";
}
if (!empty($msg_id)) {
$part_two_text[] = 'Original-Message-ID: rfc822;' . $msg_id . "\n";
}
$part_two_text[] = $dispo . "\n";
if (in_array('error', $mod) && isset($err['error'])) {
$part_two_text[] = 'Error: ' . $err['error'] . "\n";
}
$part_two->setContents($part_two_text);
$msg->addPart($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($this->_headers->toString());
if (!empty($this->_msgtext)) {
$part_three_text[] = $part_three->getEOL() . $this->_msgtext;
//.........这里部分代码省略.........