Skip to content

Commit

Permalink
Check whether a message is an auto reply based on configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
larhip committed May 4, 2022
1 parent 9cc2234 commit d0fccfa
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
30 changes: 30 additions & 0 deletions classes/emailmessage.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,4 +466,34 @@ protected function IsNewPartLine($sLine, $aDelimiterPatterns)
}
return null;
}

/**
* Check whether the message is an auto reply
* @return bool
* @since 3.5.1
*/
public function IsAutoReplyEmail()
{
$aAutoReplyHeaderPatterns = array(
'auto-submitted' => '/^auto-replied.*$/i',
);
if (class_exists('MetaModel'))
{
$aAutoReplyHeaderPatterns = MetaModel::GetModuleSetting('combodo-email-synchro', 'auto_reply_header_patterns', $aAutoReplyHeaderPatterns);
}
foreach ($aAutoReplyHeaderPatterns as $sHeader => $sPattern) {
if(array_key_exists(strtolower($sHeader), $this->aHeaders))
{
IssueLog::Info("Header \"$sHeader\" exists with the value: \"" . $this->aHeaders[strtolower($sHeader)] . "\"");
if (preg_match($sPattern, $this->aHeaders[strtolower($sHeader)]))
{
// Current mail is an auto reply
IssueLog::Info("Given mail is an autoreply!");
return true;
}
}
}

return false;
}
}
3 changes: 3 additions & 0 deletions module.combodo-email-synchro.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
'images_minimum_size' => '100x20', // Images smaller that these dimensions will be ignored (signatures...)
'images_maximum_size' => '', // Images bigger that these dimensions will be resized before uploading into iTop
'recommended_max_allowed_packet' => 10*1024*1024, // MySQL parameter for attachments
'auto_reply_header_patterns' => array (
'auto-submitted' => '/^auto-replied.*$/i',
),
),
)
);
Expand Down

0 comments on commit d0fccfa

Please sign in to comment.