Skip to content

Commit 68803f2

Browse files
committed
Check whether a message is an auto reply based on configuration
1 parent 3c90563 commit 68803f2

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

classes/emailmessage.class.inc.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,4 +466,33 @@ protected function IsNewPartLine($sLine, $aDelimiterPatterns)
466466
}
467467
return null;
468468
}
469+
470+
/**
471+
* Check whether the message is an auto reply
472+
* @return bool
473+
*/
474+
public function IsAutoReplyEmail()
475+
{
476+
$aAutoReplyHeaderPatterns = array(
477+
'auto-submitted' => '/^auto-replied.*$/i',
478+
);
479+
if (class_exists('MetaModel'))
480+
{
481+
$aAutoReplyHeaderPatterns = MetaModel::GetModuleSetting('combodo-email-synchro', 'auto-reply-header-patterns', $aAutoReplyHeaderPatterns);
482+
}
483+
foreach ($aAutoReplyHeaderPatterns as $sHeader => $sPattern) {
484+
if(array_key_exists(strtolower($sHeader), $this->aHeaders))
485+
{
486+
IssueLog::Info("Header \"$sHeader\" exists with the value: \"" . $this->aHeaders[strtolower($sHeader)] . "\"");
487+
if (preg_match($sPattern, $this->aHeaders[strtolower($sHeader)]))
488+
{
489+
// Current mail is an auto reply
490+
IssueLog::Info("Given mail is an autoreply!");
491+
return true;
492+
}
493+
}
494+
}
495+
496+
return false;
497+
}
469498
}

module.combodo-email-synchro.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
'images_minimum_size' => '100x20', // Images smaller that these dimensions will be ignored (signatures...)
6262
'images_maximum_size' => '', // Images bigger that these dimensions will be resized before uploading into iTop
6363
'recommended_max_allowed_packet' => 10*1024*1024, // MySQL parameter for attachments
64+
'auto-reply-header-patterns' => array (
65+
'auto-submitted' => '/^auto-replied.*$/i',
66+
),
6467
),
6568
)
6669
);

0 commit comments

Comments
 (0)