From e8a53cbd6a678dd72b89927c822e31e9d4b41376 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Thu, 21 Dec 2023 01:37:21 -0500 Subject: [PATCH] Update new mail queue function to use the proper mail from name and mail from email --- ajax.php | 2 ++ cron.php | 12 ++++++++++++ cron_ticket_email_parser.php | 8 ++++++++ functions.php | 8 ++++---- guest_pay_invoice_stripe.php | 2 ++ login.php | 4 ++++ post/invoice.php | 10 ++++++++++ post/quote.php | 2 ++ post/setting.php | 2 ++ post/ticket.php | 14 ++++++++++++++ 10 files changed, 60 insertions(+), 4 deletions(-) diff --git a/ajax.php b/ajax.php index 9071cbea..9f7e5b18 100644 --- a/ajax.php +++ b/ajax.php @@ -314,6 +314,8 @@ if (isset($_GET['share_generate_link'])) { $data = [ [ + 'from' => $config_mail_from_email, + 'from_name' => $config_mail_from_name, 'recipient' => $item_email, 'recipient_name' => $item_email, 'subject' => $subject, diff --git a/cron.php b/cron.php index cd8e7875..5ca97244 100644 --- a/cron.php +++ b/cron.php @@ -306,6 +306,8 @@ if (mysqli_num_rows($sql_scheduled_tickets) > 0) { $email_body = mysqli_real_escape_string($mysqli, "##- Please type your reply above this line -##

Hello, $contact_name

A ticket regarding \"$ticket_subject\" has been automatically created for you.

--------------------------------
$details--------------------------------

Ticket: $ticket_prefix$ticket_number
Subject: $ticket_subject
Status: Open
Portal: https://$config_base_url/portal/ticket.php?id=$id

~
$company_name
Support Department
$config_ticket_from_email
$company_phone"); $email = [ + 'from' => $config_ticket_from_email, + 'from_name' => $config_ticket_from_name, 'recipient' => $contact_email_escaped, 'recipient_name' => $contact_name_escaped, 'subject' => $email_subject, @@ -324,6 +326,8 @@ if (mysqli_num_rows($sql_scheduled_tickets) > 0) { $email_body = mysqli_real_escape_string($mysqli, "Hello,

This is a notification that a new scheduled ticket has been raised in ITFlow.
Ticket: $ticket_prefix$ticket_number
Client: $client_name
Priority: $priority
Link: https://$config_base_url/ticket.php?ticket_id=$id

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

$ticket_subject
$ticket_details"); $email = [ + 'from' => $config_ticket_from_email, + 'from_name' => $config_ticket_from_name, 'recipient' => $config_ticket_new_ticket_notification_email, 'recipient_name' => $config_ticket_from_name_escaped, 'subject' => $email_subject, @@ -428,6 +432,8 @@ if ($config_ticket_autoclose == 1) { $data = [ [ + 'from' => $config_ticket_from_email, + 'from_name' => $config_ticket_from_name, 'recipient' => $contact_email, 'recipient_name' => $contact_name, 'subject' => $subject, @@ -509,6 +515,8 @@ if ($config_send_invoice_reminders == 1) { $mail = addToMailQueue($mysqli, [ [ + 'from' => $config_invoice_from_email, + 'from_name' => $config_invoice_from_name, 'recipient' => $contact_email, 'recipient_name' => $contact_name, 'subject' => $subject, @@ -624,6 +632,8 @@ while ($row = mysqli_fetch_array($sql_recurring)) { $mail = addToMailQueue($mysqli, [ [ + 'from' => $config_invoice_from_email, + 'from_name' => $config_invoice_from_name, 'recipient' => $contact_email, 'recipient_name' => $contact_name, 'subject' => $subject, @@ -657,6 +667,8 @@ while ($row = mysqli_fetch_array($sql_recurring)) { $data = [ [ + 'from' => $config_invoice_from_email, + 'from_name' => $config_invoice_from_name, 'recipient' => $billing_contact_email, 'recipient_name' => $billing_contact_name, 'subject' => $subject, diff --git a/cron_ticket_email_parser.php b/cron_ticket_email_parser.php index 9a46b0e9..d8f54152 100644 --- a/cron_ticket_email_parser.php +++ b/cron_ticket_email_parser.php @@ -169,6 +169,8 @@ function addTicket($contact_id, $contact_name, $contact_email, $client_id, $date $body_escaped = mysqli_escape_string($mysqli, "##- 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: Open
https://$config_base_url/portal/ticket.php?id=$id

~
$company_name
Support Department
$config_ticket_from_email
$company_phone"); $data[] = [ + 'from' => $config_ticket_from_email, + 'from_name' => $config_ticket_from_name, 'recipient' => $contact_email_escaped, 'recipient_name' => $contact_name_escaped, 'subject' => $subject_escaped, @@ -191,6 +193,8 @@ function addTicket($contact_id, $contact_name, $contact_email, $client_id, $date $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"; $data[] = [ + 'from' => $config_ticket_from_email, + 'from_name' => $config_ticket_from_name, 'recipient' => $config_ticket_new_ticket_notification_email, 'recipient_name' => $config_ticket_from_name, 'subject' => $email_subject, @@ -243,6 +247,8 @@ function addReply($from_email, $date, $subject, $ticket_number, $message, $attac $data = [ [ + 'from' => $config_ticket_from_email, + 'from_name' => $config_ticket_from_name, 'recipient' => $from_email, 'recipient_name' => $from_email, 'subject' => $email_subject, @@ -341,6 +347,8 @@ function addReply($from_email, $date, $subject, $ticket_number, $message, $attac $data = [ [ + 'from' => $config_ticket_from_email, + 'from_name' => $config_ticket_from_name, 'recipient' => $tech_email_escaped, 'recipient_name' => $tech_name_escaped, 'subject' => $subject_escaped, diff --git a/functions.php b/functions.php index 47bea8a0..958ff24b 100644 --- a/functions.php +++ b/functions.php @@ -875,16 +875,16 @@ function calculateAccountBalance($mysqli, $account_id) { function addToMailQueue($mysqli, $data) { - $config_invoice_from_email = strval(getSettingValue($mysqli, 'config_invoice_from_email')); - $config_invoice_from_name = strval(getSettingValue($mysqli, 'config_invoice_from_name')); - + foreach ($data as $email) { + $from = strval($email['from']); + $from_name = strval($email['from_name']); $recipient = strval($email['recipient']); $recipient_name = strval($email['recipient_name']); $subject = strval($email['subject']); $body = strval($email['body']); - mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$recipient', email_recipient_name = '$recipient_name', email_from = '$config_invoice_from_email', email_from_name = '$config_invoice_from_name', email_subject = '$subject', email_content = '$body'"); + mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$recipient', email_recipient_name = '$recipient_name', email_from = '$from', email_from_name = '$from_name', email_subject = '$subject', email_content = '$body'"); } return true; diff --git a/guest_pay_invoice_stripe.php b/guest_pay_invoice_stripe.php index 37a9bc28..8974b865 100644 --- a/guest_pay_invoice_stripe.php +++ b/guest_pay_invoice_stripe.php @@ -346,6 +346,8 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent $data = [ [ + 'from' => $config_invoice_from_email, + 'from_name' => $config_invoice_from_name, 'recipient' => $contact_email, 'recipient_name' => $contact_name, 'subject' => $subject, diff --git a/login.php b/login.php index 86d985ef..d64330c9 100644 --- a/login.php +++ b/login.php @@ -147,6 +147,8 @@ if (isset($_POST['login'])) { $data = [ [ + 'from' => $config_mail_from_email, + 'from_name' => $config_mail_from_name, 'recipient' => $user_email, 'recipient_name' => $user_name, 'subject' => $subject, @@ -220,6 +222,8 @@ if (isset($_POST['login'])) { $body = "Hi $user_name,

A recent login to your $config_app_name account was unsuccessful due to an incorrect 2FA code. If you did not attempt this login, your credentials may be compromised.

Thanks,
ITFlow"; $data = [ [ + 'from' => $config_mail_from_email, + 'from_name' => $config_mail_from_name, 'recipient' => $user_email, 'recipient_name' => $user_name, 'subject' => $subject, diff --git a/post/invoice.php b/post/invoice.php index 50da20fe..9e7fd721 100644 --- a/post/invoice.php +++ b/post/invoice.php @@ -680,6 +680,8 @@ if (isset($_POST['add_payment'])) { // Queue Mail $email = [ + 'from' => $config_invoice_from_email, + 'from_name' => $config_invoice_from_name, 'recipient' => $contact_email_escaped, 'recipient_name' => $contact_name_escaped, 'subject' => $subject, @@ -711,6 +713,8 @@ if (isset($_POST['add_payment'])) { // Queue Mail $email = [ + 'from' => $config_invoice_from_email, + 'from_name' => $config_invoice_from_name, 'recipient' => $contact_email_escaped, 'recipient_name' => $contact_name_escaped, 'subject' => $subject, @@ -1002,6 +1006,8 @@ if (isset($_GET['email_invoice'])) { // Queue Mail $data = [ [ + 'from' => $config_invoice_from_email_escaped, + 'from_name' => $config_invoice_from_name_escaped, 'recipient' => $contact_email_escaped, 'recipient_name' => $contact_name_escaped, 'subject' => $subject, @@ -1043,6 +1049,8 @@ if (isset($_GET['email_invoice'])) { $data = [ [ + 'from' => $config_invoice_from_email, + 'from_name' => $config_invoice_from_name, 'recipient' => $billing_contact_email, 'recipient_name' => $billing_contact_name, 'subject' => $subject, @@ -1172,6 +1180,8 @@ if (isset($_GET['force_recurring'])) { $data = [ [ + 'from' => $config_invoice_from_email, + 'from_name' => $config_invoice_from_name, 'recipient' => $contact_email, 'recipient_name' => $contact_name, 'subject' => $subject, diff --git a/post/quote.php b/post/quote.php index 2b9761d3..89cc7459 100644 --- a/post/quote.php +++ b/post/quote.php @@ -397,6 +397,8 @@ if (isset($_GET['email_quote'])) { // Queue Mail $data = [ [ + 'from' => $config_quote_from_email, + 'from_name' => $config_quote_from_name, 'recipient' => $contact_email_escaped, 'recipient_name' => $contact_name_escaped, 'subject' => $subject, diff --git a/post/setting.php b/post/setting.php index 451aab94..ba463f46 100644 --- a/post/setting.php +++ b/post/setting.php @@ -158,6 +158,8 @@ if (isset($_POST['test_email_smtp'])) { $data = [ [ + 'from' => $email_from, + 'from_name' => $email_from, 'recipient' => $email_to, 'recipient_name' => 'Chap', 'subject' => $subject, diff --git a/post/ticket.php b/post/ticket.php index c4fe1571..59370566 100644 --- a/post/ticket.php +++ b/post/ticket.php @@ -121,6 +121,8 @@ if (isset($_POST['add_ticket'])) { // Queue Mail $data = [ [ + 'from' => $config_ticket_from_email, + 'from_name' => $config_ticket_from_name, 'recipient' => $contact_email_escaped, 'recipient_name' => $contact_name_escaped, 'subject' => $subject_escaped, @@ -137,6 +139,8 @@ if (isset($_POST['add_ticket'])) { // Queue Mail $data = [ [ + 'from' => $config_ticket_from_email, + 'from_name' => $config_ticket_from_name, 'recipient' => $watcher_email_escaped, 'recipient_name' => $watcher_email_escaped, 'subject' => $subject_escaped, @@ -424,6 +428,8 @@ if (isset($_POST['assign_ticket'])) { // Queue Mail $data = [ [ + 'from' => $config_ticket_from_email, + 'from_name' => $config_ticket_from_name, 'recipient' => $agent_email_escaped, 'recipient_name' => $agent_name_escaped, 'subject' => $subject_escaped, @@ -576,6 +582,8 @@ if (isset($_POST['add_ticket_reply'])) { // Email Ticket Contact // Queue Mail $data[] = [ + 'from' => $config_ticket_from_email, + 'from_name' => $config_ticket_from_name, 'recipient' => $contact_email_escaped, 'recipient_name' => $contact_name_escaped, 'subject' => $subject_escaped, @@ -590,6 +598,8 @@ if (isset($_POST['add_ticket_reply'])) { // Queue Mail $data[] = [ + 'from' => $config_ticket_from_email, + 'from_name' => $config_ticket_from_name, 'recipient' => $watcher_email_escaped, 'recipient_name' => $watcher_email_escaped, 'subject' => $subject_escaped, @@ -798,6 +808,8 @@ if (isset($_GET['close_ticket'])) { // Queue Mail $data[] = [ + 'from' => $config_ticket_from_email, + 'from_name' => $config_ticket_from_name, 'recipient' => $contact_email_escaped, 'recipient_name' => $contact_name_escaped, 'subject' => $subject_escaped, @@ -812,6 +824,8 @@ if (isset($_GET['close_ticket'])) { // Queue Mail $data[] = [ + 'from' => $config_ticket_from_email, + 'from_name' => $config_ticket_from_name, 'recipient' => $watcher_email_escaped, 'recipient_name' => $watcher_email_escaped, 'subject' => $subject_escaped,