示例#1
0
 function getCcAddressList()
 {
     return $this->struct->headers['cc'] ? Mail_Parse::parseAddressList($this->struct->headers['cc']) : null;
 }
示例#2
0
 function getReplyTo()
 {
     if (!($header = @$this->struct->headers['reply-to'])) {
         return null;
     }
     return Mail_Parse::parseAddressList($header);
 }
示例#3
0
 function getHeaderInfo($mid)
 {
     if (!($headerinfo = imap_headerinfo($this->mbox, $mid)) || !$headerinfo->from) {
         return null;
     }
     $raw_header = $this->getHeader($mid);
     $info = array('raw_header' => &$raw_header, 'headers' => $headerinfo, 'decoder' => $this, 'type' => $this->getMimeType($headerinfo));
     Signal::send('mail.decoded', $this, $info);
     $sender = $headerinfo->from[0];
     //Just what we need...
     $header = array('name' => $this->mime_decode(@$sender->personal), 'email' => trim(strtolower($sender->mailbox) . '@' . $sender->host), 'subject' => $this->mime_decode(@$headerinfo->subject), 'mid' => trim(@$headerinfo->message_id), 'header' => $raw_header, 'in-reply-to' => $headerinfo->in_reply_to, 'references' => $headerinfo->references);
     if ($replyto = $headerinfo->reply_to) {
         $header['reply-to'] = $replyto[0]->mailbox . '@' . $replyto[0]->host;
         $header['reply-to-name'] = $replyto[0]->personal;
     }
     // Put together a list of recipients
     $tolist = array();
     if ($headerinfo->to) {
         $tolist['to'] = $headerinfo->to;
     }
     if ($headerinfo->cc) {
         $tolist['cc'] = $headerinfo->cc;
     }
     //Add delivered-to address to list.
     if (stripos($header['header'], 'delivered-to:') !== false && ($dt = Mail_Parse::findHeaderEntry($header['header'], 'delivered-to', true))) {
         if ($delivered_to = Mail_Parse::parseAddressList($dt)) {
             $tolist['delivered-to'] = $delivered_to;
         }
     }
     $header['recipients'] = array();
     foreach ($tolist as $source => $list) {
         foreach ($list as $addr) {
             if (!($emailId = Email::getIdByEmail(strtolower($addr->mailbox) . '@' . $addr->host))) {
                 //Skip virtual Delivered-To addresses
                 if ($source == 'delivered-to') {
                     continue;
                 }
                 $header['recipients'][] = array('source' => sprintf(_S("Email (%s)"), $source), 'name' => $this->mime_decode(@$addr->personal), 'email' => strtolower($addr->mailbox) . '@' . $addr->host);
             } elseif (!$header['emailId']) {
                 $header['emailId'] = $emailId;
             }
         }
     }
     //See if any of the recipients is a delivered to address
     if ($tolist['delivered-to']) {
         foreach ($tolist['delivered-to'] as $addr) {
             foreach ($header['recipients'] as $i => $r) {
                 if (strcasecmp($r['email'], $addr->mailbox . '@' . $addr->host) === 0) {
                     $header['recipients'][$i]['source'] = 'delivered-to';
                 }
             }
         }
     }
     //BCCed?
     if (!$header['emailId']) {
         if ($headerinfo->bcc) {
             foreach ($headerinfo->bcc as $addr) {
                 if ($header['emailId'] = Email::getIdByEmail(strtolower($addr->mailbox) . '@' . $addr->host)) {
                     break;
                 }
             }
         }
     }
     // Ensure we have a message-id. If unable to read it out of the
     // email, use the hash of the entire email headers
     if (!$header['mid'] && $header['header']) {
         $header['mid'] = Mail_Parse::findHeaderEntry($header['header'], 'message-id');
         if (is_array($header['mid'])) {
             $header['mid'] = array_pop(array_filter($header['mid']));
         }
         if (!$header['mid']) {
             $header['mid'] = '<' . md5($header['header']) . '@local>';
         }
     }
     return $header;
 }
示例#4
0
 /**
  * Retrieve a list of all the recients of this message if the message
  * was received via email.
  *
  * Returns:
  * (array<RFC_822>) list of recipients parsed with the Mail/RFC822
  * address parsing utility. Returns an empty array if the message was
  * not received via email.
  */
 function getAllEmailRecipients()
 {
     $headers = self::getEmailHeaderArray();
     $recipients = array();
     if (!$headers) {
         return $recipients;
     }
     foreach (array('To', 'Cc') as $H) {
         if (!isset($headers[$H])) {
             continue;
         }
         if (!($all = Mail_Parse::parseAddressList($headers[$H]))) {
             continue;
         }
         $recipients = array_merge($recipients, $all);
     }
     return $recipients;
 }