Skip to content

Commit bd5621c

Browse files
committed
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.
1 parent 13d9d01 commit bd5621c

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

cron_ticket_email_parser.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function addTicket($contact_id, $contact_name, $contact_email, $client_id, $date
8787
$message = nl2br($message); // Convert newlines to <br>
8888

8989
// Wrap the message in a div with controlled line height
90-
$message = "<i>Email from: $contact_email at $date:-</i> <br><br><div style='line-height:1.5;'>$message</div>";
90+
$message = "<i>Email from: <b>$contact_name</b> &lt;$contact_email&gt; at $date:-</i> <br><br><div style='line-height:1.5;'>$message</div>";
9191

9292
$ticket_prefix_esc = mysqli_real_escape_string($mysqli, $config_ticket_prefix);
9393
$subject_esc = mysqli_real_escape_string($mysqli, $subject);
@@ -136,10 +136,9 @@ function addTicket($contact_id, $contact_name, $contact_email, $client_id, $date
136136
}
137137

138138
$data = [];
139-
if ($config_ticket_client_general_notifications == 1 && $client_id != 0) {
139+
if ($config_ticket_client_general_notifications == 1) {
140140
$subject_email = "Ticket created - [$config_ticket_prefix$ticket_number] - $subject";
141141
$body = "<i style='color: #808080'>##- Please type your reply above this line -##</i><br><br>Hello $contact_name,<br><br>Thank you for your email. A ticket regarding \"$subject\" has been automatically created for you.<br><br>Ticket: $config_ticket_prefix$ticket_number<br>Subject: $subject<br>Status: New<br>https://$config_base_url/portal/ticket.php?id=$id<br><br>--<br>$company_name - Support<br>$config_ticket_from_email<br>$company_phone";
142-
143142
$data[] = [
144143
'from' => $config_ticket_from_email,
145144
'from_name' => $config_ticket_from_name,
@@ -151,12 +150,15 @@ function addTicket($contact_id, $contact_name, $contact_email, $client_id, $date
151150
}
152151

153152
if ($config_ticket_new_ticket_notification_email) {
154-
$client_sql = mysqli_query($mysqli, "SELECT client_name FROM clients WHERE client_id = $client_id");
155-
$client_row = mysqli_fetch_array($client_sql);
156-
$client_name = sanitizeInput($client_row['client_name']);
157-
153+
if ($client_id == 0){
154+
$client_name = "Guest";
155+
} else {
156+
$client_sql = mysqli_query($mysqli, "SELECT client_name FROM clients WHERE client_id = $client_id");
157+
$client_row = mysqli_fetch_array($client_sql);
158+
$client_name = sanitizeInput($client_row['client_name']);
159+
}
158160
$email_subject = "$config_app_name - New Ticket - $client_name: $subject";
159-
$email_body = "Hello, <br><br>This is a notification that a new ticket has been raised in ITFlow. <br>Client: $client_name<br>Priority: Low (email parsed)<br>Link: https://$config_base_url/ticket.php?ticket_id=$id <br><br>--------------------------------<br><br><b>$subject</b><br>$details";
161+
$email_body = "Hello, <br><br>This is a notification that a new ticket has been raised in ITFlow. <br>Client: $client_name<br>Priority: Low (email parsed)<br>Link: https://$config_base_url/ticket.php?ticket_id=$id <br><br>--------------------------------<br><br><b>$subject</b><br>$message";
160162

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

0 commit comments

Comments
 (0)