From bd5621ce1ed8caeace5cdfbcdd02baa01b7701a8 Mon Sep 17 00:00:00 2001 From: Craig Hodges Date: Sun, 29 Sep 2024 23:46:45 -0500 Subject: [PATCH] Sends new ticket notifications to unknown (client id = 0) including logic to not process e-mail bounce messages. Fixed ticket description missing from new ticket notifications to others ().Added e-mail From: display name () to beginning of ticket description. --- cron_ticket_email_parser.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/cron_ticket_email_parser.php b/cron_ticket_email_parser.php index 7566fb490..a8aa91830 100644 --- a/cron_ticket_email_parser.php +++ b/cron_ticket_email_parser.php @@ -87,7 +87,7 @@ function addTicket($contact_id, $contact_name, $contact_email, $client_id, $date $message = nl2br($message); // Convert newlines to
// Wrap the message in a div with controlled line height - $message = "Email from: $contact_email at $date:-

$message
"; + $message = "Email from: $contact_name <$contact_email> at $date:-

$message
"; $ticket_prefix_esc = mysqli_real_escape_string($mysqli, $config_ticket_prefix); $subject_esc = mysqli_real_escape_string($mysqli, $subject); @@ -136,10 +136,9 @@ function addTicket($contact_id, $contact_name, $contact_email, $client_id, $date } $data = []; - if ($config_ticket_client_general_notifications == 1 && $client_id != 0) { + if ($config_ticket_client_general_notifications == 1) { $subject_email = "Ticket created - [$config_ticket_prefix$ticket_number] - $subject"; $body = "##- Please type your reply above this line -##

Hello $contact_name,

Thank you for your email. A ticket regarding \"$subject\" has been automatically created for you.

Ticket: $config_ticket_prefix$ticket_number
Subject: $subject
Status: New
https://$config_base_url/portal/ticket.php?id=$id

--
$company_name - Support
$config_ticket_from_email
$company_phone"; - $data[] = [ 'from' => $config_ticket_from_email, 'from_name' => $config_ticket_from_name, @@ -151,12 +150,15 @@ function addTicket($contact_id, $contact_name, $contact_email, $client_id, $date } if ($config_ticket_new_ticket_notification_email) { - $client_sql = mysqli_query($mysqli, "SELECT client_name FROM clients WHERE client_id = $client_id"); - $client_row = mysqli_fetch_array($client_sql); - $client_name = sanitizeInput($client_row['client_name']); - + if ($client_id == 0){ + $client_name = "Guest"; + } else { + $client_sql = mysqli_query($mysqli, "SELECT client_name FROM clients WHERE client_id = $client_id"); + $client_row = mysqli_fetch_array($client_sql); + $client_name = sanitizeInput($client_row['client_name']); + } $email_subject = "$config_app_name - New Ticket - $client_name: $subject"; - $email_body = "Hello,

This is a notification that a new ticket has been raised in ITFlow.
Client: $client_name
Priority: Low (email parsed)
Link: https://$config_base_url/ticket.php?ticket_id=$id

--------------------------------

$subject
$details"; + $email_body = "Hello,

This is a notification that a new ticket has been raised in ITFlow.
Client: $client_name
Priority: Low (email parsed)
Link: https://$config_base_url/ticket.php?ticket_id=$id

--------------------------------

$subject
$message"; $data[] = [ 'from' => $config_ticket_from_email, @@ -475,9 +477,11 @@ function getInboxFolder($client, $inboxNames) { } } elseif ($config_ticket_email_parse_unknown_senders) { // Parse even if the sender is unknown - - if (addTicket(0, 'Guest', $from_email, 0, $date, $subject, $message_body, $message->getAttachments(), $original_message_file)) { - $email_processed = true; + $bad_from_pattern = "/daemon|postmaster|reply|root|admin/i"; + if (!(preg_match($bad_from_pattern, $from_email))) { + if (addTicket(0, $from_name, $from_email, 0, $date, $subject, $message_body, $message->getAttachments(), $original_message_file)) { + $email_processed = true; + } } } }