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

Add delivered-to detection to mail fetcher

Duplicate delivered-to handling from mail parse as temp. solution.
parent feef63ac
Branches
Tags
No related merge requests found
......@@ -290,10 +290,20 @@ class MailFetcher {
if($headerinfo->cc)
$tolist['cc'] = $headerinfo->cc;
//Add delivered-to address to list.
if (stripos($header['header'], 'delivered-to:') !==false
&& ($dt = Mail_Parse::findHeaderEntry($header['header'], 'delivered-to'))) {
if (($delivered_to = Mail_Parse::parseAddressList($dt)))
$tolist['delivered-to'] = $delivered_to;
}
$header['recipients'] = array();
foreach($tolist as $source => $list) {
foreach($list as $addr) {
if(!($emailId=Email::getIdByEmail(strtolower($addr->mailbox).'@'.$addr->host))) {
if (!($emailId=Email::getIdByEmail(strtolower($addr->mailbox).'@'.$addr->host))) {
//Skip virtual Delivered-To addresses
if ($source == 'delivered-to') continue;
$header['recipients'][] = array(
'source' => "Email ($source)",
'name' => $this->mime_decode(@$addr->personal),
......@@ -304,6 +314,16 @@ class MailFetcher {
}
}
//See if any of the recipients is a delivered to address
if ($tolist['delivered-to']) {
foreach ($tolist['delivered-to'] as $addr) {
foreach ($header['recipients'] as $i => $r) {
if (strcasecmp($r['email'], $addr->mailbox.'@'.$addr->host) === 0)
$header['recipients'][$i]['source'] = 'delivered-to';
}
}
}
//BCCed?
if(!$header['emailId']) {
if ($headerinfo->bcc) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment