diff --git a/include/api.tickets.php b/include/api.tickets.php index f7b8ce357ea62e964af7a31f72b5b79fcf00cfc3..2f819790a2461d329d5f14351dcb57c14db34581 100644 --- a/include/api.tickets.php +++ b/include/api.tickets.php @@ -19,7 +19,8 @@ class TicketApiController extends ApiController { ); if(!strcasecmp($format, 'email')) - $supported = array_merge($supported, array('header', 'mid', 'emailId', 'ticketId')); + $supported = array_merge($supported, array('header', 'mid', + 'emailId', 'ticketId', 'reply-to', 'reply-to-name')); return $supported; } diff --git a/include/class.filter.php b/include/class.filter.php index 182e47ca05889335c8a0df05f9b3c96b27f34dda..df351c8a7b75a9231b384d4584ca6032e4a78d7b 100644 --- a/include/class.filter.php +++ b/include/class.filter.php @@ -651,8 +651,10 @@ class TicketFilter { 'subject' => $vars['subject'], 'name' => $vars['name'], 'body' => $vars['message'], - 'emailId' => $vars['emailId']) - )); + 'emailId' => $vars['emailId'], + 'reply-to' => @$vars['reply-to'], + 'reply-to-name' => @$vars['reply-to-name'], + ))); //Init filters. $this->build(); diff --git a/include/class.mailfetch.php b/include/class.mailfetch.php index 183874799130464ae66ba67a9553f80e310b56a0..5e58ab5a51a1d73692db077f9a6cd7d6faf2f3ca 100644 --- a/include/class.mailfetch.php +++ b/include/class.mailfetch.php @@ -235,6 +235,11 @@ class MailFetcher { 'header' => $this->getHeader($mid), ); + if ($replyto = $headerinfo->reply_to) { + $header['reply-to'] = $replyto[0]->mailbox.'@'.$replyto[0]->host; + $header['reply-to-name'] = $replyto[0]->personal; + } + //Try to determine target email - useful when fetched inbox has // aliases that are independent emails within osTicket. $emailId = 0; @@ -399,14 +404,11 @@ class MailFetcher { if($mailinfo['mid'] && ($id=Ticket::getIdByMessageId($mailinfo['mid'], $mailinfo['email']))) return true; //Reporting success so the email can be moved or deleted. - $vars = array(); - $vars['email']=$mailinfo['email']; + $vars = $mailinfo; $vars['name']=$this->mime_decode($mailinfo['name']); $vars['subject']=$mailinfo['subject']?$this->mime_decode($mailinfo['subject']):'[No Subject]'; $vars['message']=Format::stripEmptyLines($this->getBody($mid)); - $vars['header']=$mailinfo['header']; $vars['emailId']=$mailinfo['emailId']?$mailinfo['emailId']:$this->getEmailId(); - $vars['mid']=$mailinfo['mid']; //Missing FROM name - use email address. if(!$vars['name']) diff --git a/include/class.mailparse.php b/include/class.mailparse.php index 9082d6d5eb5e9b562f8afd2e6cc42bbb567dddc8..d224b9fe739a2f1db30cef8713cbe0ef4737d38b 100644 --- a/include/class.mailparse.php +++ b/include/class.mailparse.php @@ -152,6 +152,10 @@ class Mail_Parse { return $this->struct->headers['subject']; } + function getReplyTo() { + return Mail_Parse::parseAddressList($this->struct->headers['reply-to']); + } + function getBody(){ $body=''; @@ -337,6 +341,13 @@ class EmailDataParser { $data['priorityId'] = $parser->getPriority(); $data['emailId'] = $emailId; + if ($replyto = $parser->getReplyTo()) { + $replyto = $replyto[0]; + $data['reply-to'] = $replyto->mailbox.'@'.$replyto->host; + if ($replyto->personal) + $data['reply-to-name'] = trim($replyto->personal, " \t\n\r\0\x0B\x22"); + } + if($cfg && $cfg->allowEmailAttachments()) $data['attachments'] = $parser->getAttachments();