diff --git a/include/class.mailparse.php b/include/class.mailparse.php index 5cc22c97c0b14b1f948ed37dd3bcc2734d8635ff..7f90a748e4fdb459ef68c3d1a29ef8817531d63c 100644 --- a/include/class.mailparse.php +++ b/include/class.mailparse.php @@ -171,7 +171,7 @@ class Mail_Parse { return Mail_Parse::parseAddressList($header); } - function getDeliveredTOAddressList() { + function getDeliveredToAddressList() { if (!($header = $this->struct->headers['delivered-to'])) return null; @@ -463,7 +463,12 @@ class EmailDataParser { $data['name'] = $data['email']; } - //TO Address:Try to figure out the email address... associated with the incoming email. + /* Scan through the list of addressees (via To, Cc, and Delivered-To headers), and identify + * how the mail arrived at the system. One of the mails should be in the system email list. + * The recipient list (without the Delivered-To addressees) will be made available to the + * ticket filtering system. However, addresses in the Delivered-To header should never be + * considered for the collaborator list. + */ $data['emailId'] = 0; $data['recipients'] = array(); $tolist = array(); @@ -474,13 +479,13 @@ class EmailDataParser { $tolist['cc'] = $cc; if (($dt = $parser->getDeliveredToAddressList())) - $tolist['dt'] = $dt; + $tolist['delivered-to'] = $dt; 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 == 'dt') continue; + if ($source == 'delivered-to') continue; $data['recipients'][] = array( 'source' => "Email ($source)", @@ -492,6 +497,22 @@ class EmailDataParser { } } + /* + * In the event that the mail was delivered to the system although none of the system + * mail addresses are in the addressee lists, be careful not to include the addressee + * in the collaborator list. Therefore, the delivered-to addressees should be flagged so they + * are not added to the collaborator list in the ticket creation process. + */ + if ($tolist['delivered-to']) { + foreach ($tolist['delivered-to'] as $addr) { + foreach ($data['recipients'] as $i=>$r) { + if (strcasecmp($r['email'], $addr->mailbox.'@'.$addr->host) === 0) + $data['recipients'][$i]['source'] = 'delivered-to'; + } + } + } + + //maybe we got BCC'ed?? if(!$data['emailId']) { $emailId = 0; diff --git a/include/class.ticket.php b/include/class.ticket.php index 827f6d944709e894968e16ae1696a6f7fd76fc37..fd407d922896498450ff72ed93ad78a70895e584 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -1531,6 +1531,10 @@ class Ticket { 'isactive' => ($message->getUserId() == $this->getUserId())? 1: 0); $collabs = array(); foreach ($vars['recipients'] as $recipient) { + // Skip virtual delivered-to addresses + if (strcasecmp($recipient['source'], 'delivered-to') === 0) + continue; + if (($user=User::fromVars($recipient))) if ($c=$this->addCollaborator($user, $info, $errors)) $collabs[] = sprintf('%s%s',