Skip to content
Snippets Groups Projects
Commit 15c6f5a7 authored by Jared Hancock's avatar Jared Hancock
Browse files

Predictable message-ids

Outbound message-ids are predictable, with a consistent code unique and
static to each osTicket installation. This will help detect email loops
where message is delivered back to the system in an email loop.
parent f954d69f
No related branches found
No related tags found
No related merge requests found
......@@ -100,7 +100,9 @@ class Mailer {
$subject = preg_replace("/(\r\n|\r|\n)/s",'', trim($subject));
/* Message ID - generated for each outgoing email */
$messageId = sprintf('<%s-%s>', Misc::randCode(16),
$messageId = sprintf('<%s-%s-%s>',
substr(md5('mail'.SECRET_SALT), -9),
Misc::randCode(9),
($this->getEmail()?$this->getEmail()->getEmail():'@osTicketMailer'));
$headers = array (
......
......@@ -618,6 +618,19 @@ Class ThreadEntry {
// Reporting success so the email can be moved or deleted.
return true;
// Mail sent by this system will have a message-id format of
// <code-random-mailbox@domain.tld>
// where code is a predictable string based on the SECRET_SALT of
// this osTicket installation. If this incoming mail matches the
// code, then it very likely originated from this system and looped
@list($code) = explode('-', $mailinfo['mid'], 2);
if (0 === strcasecmp(ltrim($code, '<'), substr(md5('mail'.SECRET_SALT), -9))) {
// This mail was sent by this system. It was received due to
// some kind of mail delivery loop. It should not be considered
// a response to an existing thread entry
return true;
}
$vars = array(
'mid' => $mailinfo['mid'],
'header' => $mailinfo['header'],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment