Skip to content
Snippets Groups Projects
Commit 3b7bb04b authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #669 from greezybacon/feature/filter-reply-to


Support Reply-To headers in ticket filters

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents 5a44b5a2 ea1e647a
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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();
......
......@@ -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'])
......
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment