class.zmailfetch.php (cont) function getLastError() { $last_error = error_get_last(); $last_error_msg = $last_error; return $last_error_msg; } function getMimeType($struct) { $mimeType = array('TEXT', 'MULTIPART', 'MESSAGE', 'APPLICATION', 'AUDIO', 'IMAGE', 'VIDEO', 'OTHER'); if(!$struct || !$struct->subtype) return 'TEXT/PLAIN'; return $mimeType.'/'.$struct->subtype; } function getHeaderInfo($mid) { $mailmsg = $zmail_storage->getMessage($mid); if(!($headerinfo=$mailmsg->getHeader()) || !$headerinfo->from) return null; $sender=$headerinfo->from; //Just what we need... $header=array('name' =>@$sender->personal, 'email' => trim(strtolower($sender->mailbox).'@'.$sender->host), 'subject'=>@$headerinfo->subject, 'mid' => trim(@$headerinfo->message_id), 'header' => $this->getHeader($mid), 'in-reply-to' => $headerinfo->in_reply_to, 'references' => $headerinfo->references, ); if ($replyto = $headerinfo->reply_to) { $header = $replyto->mailbox.'@'.$replyto->host; $header = $replyto->personal; } //Try to determine target email - useful when fetched inbox has // aliases that are independent emails within osTicket. $emailId = 0; $tolist = array(); if($headerinfo->to) $tolist = array_merge($tolist, $headerinfo->to); if($headerinfo->cc) $tolist = array_merge($tolist, $headerinfo->cc); if($headerinfo->bcc) $tolist = array_merge($tolist, $headerinfo->bcc); foreach($tolist as $addr) if(($emailId=Email:(strtolower($addr->mailbox).'@'.$addr->host))) break; $header = $emailId; // 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 && $header) if (!($header = Mail_Parse:($header, 'message-id'))) $header = '<' . md5($header) . '@local>'; return $header; }