From d56c8a91d1cd19fc9584780787b040e7b94bd330 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Tue, 19 Sep 2023 02:13:46 -0400 Subject: [PATCH] Fix a possible race condition with duplicating tickets: Revert marking Email body peeking and flag all other emails not matching the ticket parser --- cron_ticket_email_parser.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cron_ticket_email_parser.php b/cron_ticket_email_parser.php index 80aad64c..a098f84a 100644 --- a/cron_ticket_email_parser.php +++ b/cron_ticket_email_parser.php @@ -336,7 +336,7 @@ if ($emails) { $email_processed = false; // Get details from message and invoke PHP Mime Mail Parser - $msg_to_parse = imap_fetchheader($imap, $email, FT_PREFETCHTEXT) . imap_body($imap, $email, FT_PEEK); + $msg_to_parse = imap_fetchheader($imap, $email, FT_PREFETCHTEXT) . imap_body($imap, $email); $parser = new PhpMimeMailParser\Parser(); $parser->setText($msg_to_parse); @@ -430,9 +430,12 @@ if ($emails) { // Deal with the message (move it if processed, flag it if not) if ($email_processed) { - imap_setflag_full($imap, $email, "\\Seen"); + //imap_setflag_full($imap, $email, "\\Seen"); imap_mail_move($imap, $email, $imap_folder); - } + } else { + echo "Failed to process email - flagging for manual review."; + imap_setflag_full($imap, $email, "\\Flagged"); + } }