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

Make sure Delivered-To addresses are NOT added as collaborators

parent c73a3571
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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',
......
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