Skip to content

Commit 0ce8062

Browse files
committed
Check whether a message is an auto reply based on configuration
1 parent 4af5f5e commit 0ce8062

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

classes/emailmessage.class.inc.php

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

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)