本文整理汇总了PHP中Horde_Mime::generateMessageId方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Mime::generateMessageId方法的具体用法?PHP Horde_Mime::generateMessageId怎么用?PHP Horde_Mime::generateMessageId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Mime
的用法示例。
在下文中一共展示了Horde_Mime::generateMessageId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendRedirectMessage
/**
* Send a redirect (a/k/a resent) message. See RFC 5322 [3.6.6].
*
* @param mixed $to The addresses to redirect to.
* @param boolean $log Whether to log the resending in the history and
* sentmail log.
*
* @return array An object with the following properties for each
* redirected message:
* - contents: (IMP_Contents) The contents object.
* - headers: (Horde_Mime_Headers) The header object.
* - mbox: (IMP_Mailbox) Mailbox of the message.
* - uid: (string) UID of the message.
*
* @throws IMP_Compose_Exception
*/
public function sendRedirectMessage($to, $log = true)
{
global $injector, $registry;
$recip = $this->recipientList(array('to' => $to));
$identity = $injector->getInstance('IMP_Identity');
$from_addr = $identity->getFromAddress();
$out = array();
foreach ($this->getMetadata('redirect_indices') as $val) {
foreach ($val->uids as $val2) {
try {
$contents = $injector->getInstance('IMP_Factory_Contents')->create($val->mbox->getIndicesOb($val2));
} catch (IMP_Exception $e) {
throw new IMP_Compose_Exception(_("Error when redirecting message."));
}
$headers = $contents->getHeader();
/* We need to set the Return-Path header to the current user -
* see RFC 2821 [4.4]. */
$headers->removeHeader('return-path');
$headers->addHeader('Return-Path', $from_addr);
/* Generate the 'Resent' headers (RFC 5322 [3.6.6]). These
* headers are prepended to the message. */
$resent_headers = new Horde_Mime_Headers();
$resent_headers->addHeader('Resent-Date', date('r'));
$resent_headers->addHeader('Resent-From', $from_addr);
$resent_headers->addHeader('Resent-To', $recip['header']['to']);
$resent_headers->addHeader('Resent-Message-ID', Horde_Mime::generateMessageId());
$header_text = trim($resent_headers->toString(array('encode' => 'UTF-8'))) . "\n" . trim($contents->getHeader(IMP_Contents::HEADER_TEXT));
$this->_prepSendMessageAssert($recip['list']);
$to = $this->_prepSendMessage($recip['list']);
$hdr_array = $headers->toArray(array('charset' => 'UTF-8'));
$hdr_array['_raw'] = $header_text;
try {
$injector->getInstance('IMP_Mail')->send($to, $hdr_array, $contents->getBody());
} catch (Horde_Mail_Exception $e) {
$e2 = new IMP_Compose_Exception($e);
if (($prev = $e->getPrevious()) && $prev instanceof Horde_Smtp_Exception) {
Horde::log(sprintf("SMTP Error: %s (%u; %s)", $prev->raw_msg, $prev->getCode(), $prev->getEnhancedSmtpCode() ?: 'N/A'), 'ERR');
$e2->logged = true;
}
throw $e2;
}
$recipients = strval($recip['list']);
Horde::log(sprintf("%s Redirected message sent to %s from %s", $_SERVER['REMOTE_ADDR'], $recipients, $registry->getAuth()), 'INFO');
if ($log) {
/* Store history information. */
$msg_id = new Horde_Mail_Rfc822_Identification($headers->getValue('message-id'));
$injector->getInstance('IMP_Maillog')->log(new IMP_Maillog_Message(reset($msg_id->ids)), new IMP_Maillog_Log_Redirect($recipients));
$injector->getInstance('IMP_Sentmail')->log(IMP_Sentmail::REDIRECT, reset($msg_id->ids), $recipients);
}
$tmp = new stdClass();
$tmp->contents = $contents;
$tmp->headers = $headers;
$tmp->mbox = $val->mbox;
$tmp->uid = $val2;
$out[] = $tmp;
}
}
return $out;
}
示例2: addMessageIdHeader
/**
* Generate the 'Message-ID' header.
*/
public function addMessageIdHeader()
{
$this->addHeader('Message-ID', Horde_Mime::generateMessageId());
}
示例3: mail
//.........这里部分代码省略.........
$mycomments = Whups::permissionsFilter($comments, 'comment', Horde_Perms::READ, '');
$to = $mail_always;
} else {
$details = Whups::getUserAttributes($user);
if (!empty($details['email'])) {
$to = Whups::formatUser($details);
$mycomments = Whups::permissionsFilter($comments, 'comment', Horde_Perms::READ, $details['user']);
}
$full_name = $details['name'];
}
/* We may have no recipients due to users excluding themselves
* from self notifies. */
if (!$to) {
continue;
}
if ($details && $details['type'] == 'user') {
$user_prefs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Prefs')->create('whups', array('user' => $details['user']));
if ($from['type'] == 'user' && $details['user'] == $from['user'] && $user_prefs->getValue('email_others_only')) {
continue;
}
}
if ($opts['ticket']) {
/* Add attachments. */
$attachmentAdded = false;
if (empty($GLOBALS['conf']['mail']['link_attach'])) {
/* We need to remove all attachments because the attachment
* list is potentially limited by permissions. */
$mail->clearParts();
foreach ($mycomments as $comment) {
foreach ($comment['changes'] as $change) {
if ($change['type'] != 'attachment') {
continue;
}
foreach ($attachments as $attachment) {
if ($attachment['name'] != $change['value']) {
continue;
}
if (!isset($attachment['part'])) {
$attachment['part'] = new Horde_Mime_Part();
$attachment['part']->setType(Horde_Mime_Magic::filenameToMime($change['value'], false));
$attachment['part']->setDisposition('attachment');
$attachment['part']->setContents($vfs->read(Whups::VFS_ATTACH_PATH . '/' . $opts['ticket']->getId(), $change['value']));
$attachment['part']->setName($change['value']);
}
$mail->addMimePart($attachment['part']);
$attachmentAdded = true;
break;
}
}
}
}
$formattedComment = $this->formatComments($mycomments, $opts['ticket']->getId());
if (!$attachmentAdded && !strlen(trim($formattedComment)) && $details && $details['type'] == 'user' && $user_prefs->getValue('email_comments_only')) {
continue;
}
$opts['view']->comment = $formattedComment;
}
$addr_ob = new Horde_Mail_Rfc822_Address($to);
if ($addr_ob->valid) {
$bare_address = $addr_ob->bare_address;
if (!empty($seen_email_addresses[$bare_address])) {
continue;
}
$seen_email_addresses[$bare_address] = true;
if (empty($full_name) && !is_null($addr_ob->personal)) {
$full_name = $addr_ob->personal;
}
}
// Use email address as fallback.
if (empty($full_name)) {
$full_name = $to;
}
$opts['view']->full_name = $full_name;
$opts['view']->role = $role;
$body = $opts['view']->render($opts['template']);
if (!strlen(trim($body))) {
continue;
}
$mail->setBody($body);
$mail->addHeader('Message-ID', Horde_Mime::generateMessageId());
if ($opts['ticket']) {
$message_id = '<whups-' . $opts['ticket']->getId() . '-' . md5($user) . '@' . $conf['server']['name'] . '>';
if ($opts['new']) {
$mail->addHeader('Message-ID', $message_id);
} else {
$mail->addHeader('In-Reply-To', $message_id);
$mail->addHeader('References', $message_id);
}
}
$mail->clearRecipients();
$mail->addHeader('To', $to);
try {
$mail->send($GLOBALS['injector']->getInstance('Horde_Mail'), true);
$entry = sprintf('%s Message sent to %s from "%s"', $_SERVER['REMOTE_ADDR'], $to, $GLOBALS['registry']->getAuth());
Horde::log($entry, 'INFO');
} catch (Horde_Mime_Exception $e) {
Horde::log($e, 'ERR');
}
}
}