diff --git a/ajax.php b/ajax.php index 991883f9..9071cbea 100644 --- a/ajax.php +++ b/ajax.php @@ -312,10 +312,16 @@ if (isset($_GET['share_generate_link'])) { } $body = "Hello,

$session_name from $session_company_name sent you a time sensitive secure link regarding '$item_name'.

The link will expire in $item_expires_friendly and may only be viewed $item_view_limit times, before the link is destroyed.

Click here to access your secure content

~
$session_company_name
Support Department
$config_ticket_from_email"; - $mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port, - $config_mail_from_email, $config_mail_from_name, - $item_email, $item_email, - $subject, $body); + $data = [ + [ + 'recipient' => $item_email, + 'recipient_name' => $item_email, + 'subject' => $subject, + 'body' => $body, + ] + ]; + + $mail = addToMailQueue($mysqli, $data); if ($mail !== true) { mysqli_query($mysqli,"INSERT INTO notifications SET notification_type = 'Mail', notification = 'Failed to send email to $item_email'"); diff --git a/cron.php b/cron.php index 016364d6..cd8e7875 100644 --- a/cron.php +++ b/cron.php @@ -426,10 +426,15 @@ if ($config_ticket_autoclose == 1) { $subject = "Ticket pending closure - [$ticket_prefix$ticket_number] - $ticket_subject"; $body = "##- Please type your reply above this line -##

Hello, $contact_name

This is an automatic friendly reminder that your ticket regarding \"$ticket_subject\" will be closed, unless you respond.

--------------------------------
$ticket_reply--------------------------------

If your issue is resolved, you can ignore this email - the ticket will automatically close. If you need further assistance, please respond to this email.

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

~
$company_name
Support Department
$config_ticket_from_email
$company_phone"; - $mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port, - $config_ticket_from_email, $config_ticket_from_name, - $contact_email, $contact_name, - $subject, $body); + $data = [ + [ + 'recipient' => $contact_email, + 'recipient_name' => $contact_name, + 'subject' => $subject, + 'body' => $body + ] + ]; + $mail = addToMailQueue($mysqli, $data); if ($mail !== true) { mysqli_query($mysqli,"INSERT INTO notifications SET notification_type = 'Mail', notification = 'Failed to send email to $contact_email'"); @@ -502,19 +507,14 @@ if ($config_send_invoice_reminders == 1) {

Kindly review the invoice details mentioned below.

Invoice: $invoice_prefix$invoice_number
Issue Date: $invoice_date
Total: " . numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code) . "
Due Date: $invoice_due


To view your invoice click here


~
$company_name
Billing Department
$config_invoice_from_email
$company_phone"; - $mail = sendSingleEmail( - $config_smtp_host, - $config_smtp_username, - $config_smtp_password, - $config_smtp_encryption, - $config_smtp_port, - $config_invoice_from_email, - $config_invoice_from_name, - $contact_email, - $contact_name, - $subject, - $body - ); + $mail = addToMailQueue($mysqli, [ + [ + 'recipient' => $contact_email, + 'recipient_name' => $contact_name, + 'subject' => $subject, + 'body' => $body + ] + ]); if ($mail === true) { mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Sent', history_description = 'Cron Emailed Overdue Invoice', history_invoice_id = $invoice_id"); @@ -622,19 +622,14 @@ while ($row = mysqli_fetch_array($sql_recurring)) { $subject = "Invoice $invoice_prefix$invoice_number"; $body = "Hello $contact_name,

Kindly review the invoice details mentioned below.

Invoice: $invoice_prefix$invoice_number
Issue Date: $invoice_date
Total: " . numfmt_format_currency($currency_format, $invoice_amount, $recurring_currency_code) . "
Due Date: $invoice_due


To view your invoice click here


~
$company_name
Billing Department
$config_invoice_from_email
$company_phone"; - $mail = sendSingleEmail( - $config_smtp_host, - $config_smtp_username, - $config_smtp_password, - $config_smtp_encryption, - $config_smtp_port, - $config_invoice_from_email, - $config_invoice_from_name, - $contact_email, - $contact_name, - $subject, - $body - ); + $mail = addToMailQueue($mysqli, [ + [ + 'recipient' => $contact_email, + 'recipient_name' => $contact_name, + 'subject' => $subject, + 'body' => $body + ] + ]); if ($mail === true) { mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Sent', history_description = 'Cron Emailed Invoice!', history_invoice_id = $new_invoice_id"); @@ -660,10 +655,16 @@ while ($row = mysqli_fetch_array($sql_recurring)) { $billing_contact_name = $billing_contact['contact_name']; $billing_contact_email = $billing_contact['contact_email']; - sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port, - $config_invoice_from_email, $config_invoice_from_name, - $billing_contact_email, $billing_contact_name, - $subject, $body); + $data = [ + [ + 'recipient' => $billing_contact_email, + 'recipient_name' => $billing_contact_name, + 'subject' => $subject, + 'body' => $body + ] + ]; + + addToMailQueue($mysqli, $data); } } //End if Autosend is on diff --git a/cron_ticket_email_parser.php b/cron_ticket_email_parser.php index 4b4451d6..9a46b0e9 100644 --- a/cron_ticket_email_parser.php +++ b/cron_ticket_email_parser.php @@ -240,20 +240,17 @@ function addReply($from_email, $date, $subject, $ticket_number, $message, $attac $email_subject = "Action required: This ticket is already closed"; $email_body = "Hi there,

You've tried to reply to a ticket that is closed - we won't see your response.

Please raise a new ticket by sending a fresh e-mail to our support address.

~
$company_name
Support Department
$config_ticket_from_email
$company_phone"; - - sendSingleEmail( - $config_smtp_host, - $config_smtp_username, - $config_smtp_password, - $config_smtp_encryption, - $config_smtp_port, - $config_ticket_from_email, - $config_ticket_from_name, - $from_email, - $from_email, - $email_subject, - $email_body - ); + + $data = [ + [ + 'recipient' => $from_email, + 'recipient_name' => $from_email, + 'subject' => $email_subject, + 'body' => $email_body + ] + ]; + + addToMailQueue($mysqli, $data); return false; } diff --git a/guest_pay_invoice_stripe.php b/guest_pay_invoice_stripe.php index c909ac8d..37a9bc28 100644 --- a/guest_pay_invoice_stripe.php +++ b/guest_pay_invoice_stripe.php @@ -344,19 +344,15 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent $subject = "Payment Received - Invoice $invoice_prefix$invoice_number"; $body = "Hello $contact_name,

We have received your payment in the amount of " . $pi_currency . $pi_amount_paid . " for invoice $invoice_prefix$invoice_number. Please keep this email as a receipt for your records.

Amount: " . numfmt_format_currency($currency_format, $pi_amount_paid, $invoice_currency_code) . "
Balance: " . numfmt_format_currency($currency_format, '0', $invoice_currency_code) . "

Thank you for your business!


~
$company_name
Billing Department
$config_invoice_from_email
$company_phone"; - $mail = sendSingleEmail( - $config_smtp_host, - $config_smtp_username, - $config_smtp_password, - $config_smtp_encryption, - $config_smtp_port, - $config_invoice_from_email, - $config_invoice_from_name, - $contact_email, - $contact_name, - $subject, - $body - ); + $data = [ + [ + 'recipient' => $contact_email, + 'recipient_name' => $contact_name, + 'subject' => $subject, + 'body' => $body, + ] + ]; + $mail = addToMailQueue($mysqli, $data); // Email Logging if ($mail === true) { diff --git a/login.php b/login.php index 305110ff..86d985ef 100644 --- a/login.php +++ b/login.php @@ -145,19 +145,15 @@ if (isset($_POST['login'])) { $subject = "$config_app_name new login for $user_name"; $body = "Hi $user_name,

A recent successful login to your $config_app_name account was considered a little unusual. If this was you, you can safely ignore this email!

IP Address: $ip
User Agent: $user_agent

If you did not perform this login, your credentials may be compromised.

Thanks,
ITFlow"; - $mail = sendSingleEmail( - $config_smtp_host, - $config_smtp_username, - $config_smtp_password, - $config_smtp_encryption, - $config_smtp_port, - $config_mail_from_email, - $config_mail_from_name, - $user_email, - $user_name, - $subject, - $body - ); + $data = [ + [ + 'recipient' => $user_email, + 'recipient_name' => $user_name, + 'subject' => $subject, + 'body' => $body + ] + ]; + addToMailQueue($mysqli, $data); } @@ -222,20 +218,15 @@ if (isset($_POST['login'])) { if (!empty($config_smtp_host)) { $subject = "Important: $config_app_name failed 2FA login attempt for $user_name"; $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"; - - $mail = sendSingleEmail( - $config_smtp_host, - $config_smtp_username, - $config_smtp_password, - $config_smtp_encryption, - $config_smtp_port, - $config_mail_from_email, - $config_mail_from_name, - $user_email, - $user_name, - $subject, - $body - ); + $data = [ + [ + 'recipient' => $user_email, + 'recipient_name' => $user_name, + 'subject' => $subject, + 'body' => $body + ] + ]; + $mail = addToMailQueue($mysqli, $data); } // HTML feedback for incorrect 2FA code diff --git a/portal/login_reset.php b/portal/login_reset.php index 33a2939c..31a1b26f 100644 --- a/portal/login_reset.php +++ b/portal/login_reset.php @@ -71,19 +71,15 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $subject = "Password reset for $company_name ITFlow Portal"; $body = "Hello, $name

Someone (probably you) has requested a new password for your account on $company_name's ITFlow Client Portal.

Please click here to reset your password.

Alternatively, copy and paste this URL into your browser:
$url

If you didn't request this change, you can safely ignore this email.

~
$company_name
Support Department
$config_mail_from_email"; - $mail = sendSingleEmail( - $config_smtp_host, - $config_smtp_username, - $config_smtp_password, - $config_smtp_encryption, - $config_smtp_port, - $config_mail_from_email, - $config_mail_from_name, - $email, - $name, - $subject, - $body - ); + $data = [ + [ + 'recipient' => $email, + 'recipient_name' => $name, + 'subject' => $subject, + 'body' => $body + ] + ]; + $mail = addToMailQueue($mysqli, $data); // Error handling if ($mail !== true) { @@ -130,19 +126,16 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $body = "Hello, $name

Your password for your account on $company_name's ITFlow Client Portal was successfully reset. You should be all set!

If you didn't reset your password, please get in touch ASAP.

~
$company_name
Support Department
$config_mail_from_email"; - $mail = sendSingleEmail( - $config_smtp_host, - $config_smtp_username, - $config_smtp_password, - $config_smtp_encryption, - $config_smtp_port, - $config_mail_from_email, - $config_mail_from_name, - $email, - $name, - $subject, - $body - ); + $data = [ + [ + 'recipient' => $email, + 'recipient_name' => $name, + 'subject' => $subject, + 'body' => $body + ] + ]; + + $mail = addToMailQueue($mysqli, $data); // Error handling if ($mail !== true) { diff --git a/post/event.php b/post/event.php index 9310d449..1494bea5 100644 --- a/post/event.php +++ b/post/event.php @@ -61,10 +61,15 @@ if (isset($_POST['add_event'])) { $subject = "New Calendar Event"; $body = "Hello $contact_name,

A calendar event has been scheduled: $title at $start


~
$company_name
$company_phone"; - $mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port, - $config_mail_from_email, $config_mail_from_name, - $contact_email, $contact_name, - $subject, $body); + $data = [ + [ + 'recipient' => $contact_email, + 'recipient_name' => $contact_name, + 'subject' => $subject, + 'body' => $body + ] + ]; + $mail = addToMailQueue($mysqli, $data); // Logging for email (success/fail) if ($mail === true) { @@ -120,11 +125,15 @@ if (isset($_POST['edit_event'])) { $subject = "Calendar Event Rescheduled"; $body = "Hello $contact_name,

A calendar event has been rescheduled: $title at $start


~
$company_name
$company_phone"; - $mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port, - $config_mail_from_email, $config_mail_from_name, - $contact_email, $contact_name, - $subject, $body); - + $data = [ + [ + 'recipient' => $contact_email, + 'recipient_name' => $contact_name, + 'subject' => $subject, + 'body' => $body + ] + ]; + $mail = addToMailQueue($mysqli, $data); // Logging for email (success/fail) if ($mail === true) { mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Calendar_Event', log_action = 'Email', log_description = '$session_name Emailed modified event $title to $client_name email $client_email', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id"); diff --git a/post/invoice.php b/post/invoice.php index 2b2c8a57..56446773 100644 --- a/post/invoice.php +++ b/post/invoice.php @@ -1030,10 +1030,16 @@ if (isset($_GET['force_recurring'])) { $subject = "Invoice $invoice_prefix$invoice_number"; $body = "Hello $contact_name,

Please view the details of the invoice below.

Invoice: $invoice_prefix$invoice_number
Issue Date: $invoice_date
Total: $$invoice_amount
Due Date: $invoice_due


To view your invoice click here


~
$company_name
$company_phone"; - $mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port, - $config_invoice_from_email, $config_invoice_from_name, - $contact_email, $contact_name, - $subject, $body); + + $data = [ + [ + 'email' => $contact_email, + 'name' => $contact_name, + 'subject' => $subject, + 'body' => $body + ] + ]; + $mail = addToMailQueue($mysqli, $data); if ($mail === true) { // Add send history diff --git a/post/profile.php b/post/profile.php index 30fdc87e..c557e88b 100644 --- a/post/profile.php +++ b/post/profile.php @@ -41,10 +41,15 @@ if (isset($_POST['edit_profile'])) { $subject = "$config_app_name account update confirmation for $name"; $body = "Hi $name,

Your $config_app_name account has been updated, details below:

$details

If you did not perform this change, contact your $config_app_name administrator immediately.

Thanks,
ITFlow
$session_company_name"; - $mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port, - $config_mail_from_email, $config_mail_from_name, - $user_old_email, $name, - $subject, $body); + $data = [ + [ + 'recipient' => $user_old_email, + 'recipient_name' => $name, + 'subject' => $subject, + 'body' => $body + ] + ]; + $mail = addToMailQueue($mysqli, $data); } // Check to see if a file is attached @@ -166,10 +171,15 @@ if(isset($_POST['disable_2fa'])){ $subject = "$config_app_name account update confirmation for $session_name"; $body = "Hi $session_name,

Your $config_app_name account has been updated, details below:

2FA was disabled.

If you did not perform this change, contact your $config_app_name administrator immediately.

Thanks,
ITFlow
$session_company_name"; - $mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port, - $config_mail_from_email, $config_mail_from_name, - $session_email, $session_name, - $subject, $body); + $data = [ + [ + 'recipient' => $session_email, + 'recipient_name' => $session_name, + 'subject' => $subject, + 'body' => $body + ] + ]; + $mail = addToMailQueue($mysqli, $data); } $_SESSION['alert_type'] = "error"; diff --git a/post/setting.php b/post/setting.php index 7e41ffe4..451aab94 100644 --- a/post/setting.php +++ b/post/setting.php @@ -153,13 +153,18 @@ if (isset($_POST['test_email_smtp'])) { validateAdminRole(); $email_from = sanitizeInput($_POST['email_from']); $email_to = sanitizeInput($_POST['email_to']); - $subject = "Hi'ya there Chap"; - $body = "Hello there Chap ;) Don't worry this won't hurt a bit, it's just a test"; + $subject = "Test email from ITFlow"; + $body = "This is a test email from ITFlow. If you are reading this, it worked!"; - $mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port, - $email_from, $config_mail_from_name, - $email_to, $email_to, - $subject, $body); + $data = [ + [ + 'recipient' => $email_to, + 'recipient_name' => 'Chap', + 'subject' => $subject, + 'body' => $body + ] + ]; + $mail = addToMailQueue($mysqli, $data); if ($mail === true) { $_SESSION['alert_message'] = "Test email sent successfully"; diff --git a/post/user.php b/post/user.php index f0b1cf0c..553fe740 100644 --- a/post/user.php +++ b/post/user.php @@ -53,10 +53,15 @@ if (isset($_POST['add_user'])) { $subject = "Your new $session_company_name ITFlow account"; $body = "Hello, $name

An ITFlow account has been setup for you. Please change your password upon login.

Username: $email
Password: $_POST[password]
Login URL: https://$config_base_url/login.php?key=$config_login_key_secret

~
$session_company_name
Support Department
$config_ticket_from_email"; - $mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port, - $config_ticket_from_email, $config_ticket_from_name, - $email, $name, - $subject, $body); + $data = [ + [ + 'recipient' => $email, + 'recipient_name' => $name, + 'subject' => $subject, + 'body' => $body + ] + ]; + $mail = addToMailQueue($mysqli, $data); if ($mail !== true) { mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Mail', notification = 'Failed to send email to $email'");