Skip to content

Commit d0fccfa

Browse files
committed
Check whether a message is an auto reply based on configuration
1 parent 9cc2234 commit d0fccfa

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
@@ -466,4 +466,34 @@ 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+
* @since 3.5.1
474+
*/
475+
public function IsAutoReplyEmail()
476+
{
477+
$aAutoReplyHeaderPatterns = array(
478+
'auto-submitted' => '/^auto-replied.*$/i',
479+
);
480+
if (class_exists('MetaModel'))
481+
{
482+
$aAutoReplyHeaderPatterns = MetaModel::GetModuleSetting('combodo-email-synchro', 'auto_reply_header_patterns', $aAutoReplyHeaderPatterns);
483+
}
484+
foreach ($aAutoReplyHeaderPatterns as $sHeader => $sPattern) {
485+
if(array_key_exists(strtolower($sHeader), $this->aHeaders))
486+
{
487+
IssueLog::Info("Header \"$sHeader\" exists with the value: \"" . $this->aHeaders[strtolower($sHeader)] . "\"");
488+
if (preg_match($sPattern, $this->aHeaders[strtolower($sHeader)]))
489+
{
490+
// Current mail is an auto reply
491+
IssueLog::Info("Given mail is an autoreply!");
492+
return true;
493+
}
494+
}
495+
}
496+
497+
return false;
498+
}
469499
}

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)