From ef29a17d49561cdfe7d4a5759a48272cd716de2d Mon Sep 17 00:00:00 2001 From: johnnyq Date: Sat, 2 Apr 2022 16:03:30 -0400 Subject: [PATCH] DB Structure Update - Added SMTP Encryption Type to Mail settings --- cron-mailer.php | 3 ++- cron.php | 5 +++-- db.sql | 6 ++++-- get_settings.php | 1 + post.php | 23 ++++++++++++----------- settings-mail.php | 16 +++++++++++++++- 6 files changed, 37 insertions(+), 17 deletions(-) diff --git a/cron-mailer.php b/cron-mailer.php index f1f2159f..b9b549b5 100644 --- a/cron-mailer.php +++ b/cron-mailer.php @@ -24,6 +24,7 @@ while($row = mysqli_fetch_array($sql_companies)){ $config_smtp_username = $row['config_smtp_username']; $config_smtp_password = $row['config_smtp_password']; $config_smtp_port = $row['config_smtp_port']; + $config_smtp_encryption = $row['config_smtp_encryption']; $config_base_url = $row['config_base_url']; $sql_campaigns = mysqli_query($mysqli,"SELECT * FROM campaigns WHERE company_id = $company_id AND campaign_status = 'Queued' AND campaign_scheduled_at < NOW()"); @@ -68,7 +69,7 @@ while($row = mysqli_fetch_array($sql_companies)){ $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $config_smtp_username; // SMTP username $mail->Password = $config_smtp_password; // SMTP password - $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted + $mail->SMTPSecure = $config_smtp_encryption; // Enable TLS encryption, `ssl` also accepted $mail->Port = $config_smtp_port; // TCP port to connect to //Recipients diff --git a/cron.php b/cron.php index e0e4b93f..3a3dd061 100644 --- a/cron.php +++ b/cron.php @@ -30,6 +30,7 @@ while($row = mysqli_fetch_array($sql_companies)){ $config_smtp_username = $row['config_smtp_username']; $config_smtp_password = $row['config_smtp_password']; $config_smtp_port = $row['config_smtp_port']; + $config_smtp_encryption = $row['config_smtp_encryption']; $config_mail_from_email = $row['config_mail_from_email']; $config_mail_from_name = $row['config_mail_from_name']; $config_recurring_auto_send_invoice = $row['config_recurring_auto_send_invoice']; @@ -317,7 +318,7 @@ while($row = mysqli_fetch_array($sql_companies)){ $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $config_smtp_username; // SMTP username $mail->Password = $config_smtp_password; // SMTP password - $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted + $mail->SMTPSecure = $config_smtp_encryption; // Enable TLS encryption, `ssl` also accepted $mail->Port = $config_smtp_port; // TCP port to connect to //Recipients @@ -441,7 +442,7 @@ while($row = mysqli_fetch_array($sql_companies)){ $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $config_smtp_username; // SMTP username $mail->Password = $config_smtp_password; // SMTP password - $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted + $mail->SMTPSecure = $config_smtp_encryption; // Enable TLS encryption, `ssl` also accepted $mail->Port = $config_smtp_port; // TCP port to connect to //Recipients diff --git a/db.sql b/db.sql index dc18c68c..36abb54a 100644 --- a/db.sql +++ b/db.sql @@ -1,6 +1,6 @@ -- MariaDB dump 10.19 Distrib 10.5.15-MariaDB, for debian-linux-gnu (x86_64) -- --- Host: localhost Database: pittpc_crm +-- Host: localhost Database: itflow_dev -- ------------------------------------------------------ -- Server version 10.5.15-MariaDB-1:10.5.15+maria~focal @@ -1086,9 +1086,11 @@ DROP TABLE IF EXISTS `settings`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `settings` ( `company_id` int(11) NOT NULL, + `config_current_database_version` varchar(10) NOT NULL, `config_base_url` varchar(200) DEFAULT NULL, `config_smtp_host` varchar(200) DEFAULT NULL, `config_smtp_port` int(5) DEFAULT NULL, + `config_smtp_encryption` varchar(200) DEFAULT NULL, `config_smtp_username` varchar(200) DEFAULT NULL, `config_smtp_password` varchar(200) DEFAULT NULL, `config_mail_from_email` varchar(200) DEFAULT NULL, @@ -1485,4 +1487,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-03-29 13:38:27 +-- Dump completed on 2022-04-02 16:01:13 diff --git a/get_settings.php b/get_settings.php index 0049f586..811fc2ed 100644 --- a/get_settings.php +++ b/get_settings.php @@ -19,6 +19,7 @@ $config_azure_client_secret = $row['config_azure_client_secret']; // Mail $config_smtp_host = $row['config_smtp_host']; $config_smtp_port = $row['config_smtp_port']; +$config_smtp_encryption = $row['config_smtp_encryption']; $config_smtp_username = $row['config_smtp_username']; $config_smtp_password = $row['config_smtp_password']; $config_mail_from_email = $row['config_mail_from_email']; diff --git a/post.php b/post.php index 13582954..376a4076 100644 --- a/post.php +++ b/post.php @@ -827,12 +827,13 @@ if(isset($_POST['edit_mail_settings'])){ $config_smtp_host = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_smtp_host']))); $config_smtp_port = intval($_POST['config_smtp_port']); + $config_smtp_encryption = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_smtp_encryption']))); $config_smtp_username = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_smtp_username']))); $config_smtp_password = trim(mysqli_real_escape_string($mysqli,$_POST['config_smtp_password'])); $config_mail_from_email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_mail_from_email']))); $config_mail_from_name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_mail_from_name']))); - mysqli_query($mysqli,"UPDATE settings SET config_smtp_host = '$config_smtp_host', config_smtp_port = $config_smtp_port, config_smtp_username = '$config_smtp_username', config_smtp_password = '$config_smtp_password', config_mail_from_email = '$config_mail_from_email', config_mail_from_name = '$config_mail_from_name' WHERE company_id = $session_company_id"); + mysqli_query($mysqli,"UPDATE settings SET config_smtp_host = '$config_smtp_host', config_smtp_port = $config_smtp_port, config_smtp_encryption = '$config_smtp_encryption', config_smtp_username = '$config_smtp_username', config_smtp_password = '$config_smtp_password', config_mail_from_email = '$config_mail_from_email', config_mail_from_name = '$config_mail_from_name' WHERE company_id = $session_company_id"); //Update From Email and From Name if Invoice/Quote or Ticket fields are blank @@ -890,7 +891,7 @@ if(isset($_POST['test_email'])){ $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $config_smtp_username; // SMTP username $mail->Password = $config_smtp_password; // SMTP password - $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted + $mail->SMTPSecure = $config_smtp_encryption; // Enable TLS encryption, `ssl` also accepted $mail->Port = $config_smtp_port; // TCP port to connect to //Recipients @@ -1604,7 +1605,7 @@ if(isset($_POST['add_event'])){ $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $config_smtp_username; // SMTP username $mail->Password = $config_smtp_password; // SMTP password - $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted + $mail->SMTPSecure = $config_smtp_encryption; // Enable TLS encryption, `ssl` also accepted $mail->Port = $config_smtp_port; // TCP port to connect to //Recipients @@ -1681,7 +1682,7 @@ if(isset($_POST['edit_event'])){ $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $config_smtp_username; // SMTP username $mail->Password = $config_smtp_password; // SMTP password - $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted + $mail->SMTPSecure = $config_smtp_encryption; // Enable TLS encryption, `ssl` also accepted $mail->Port = $config_smtp_port; // TCP port to connect to //Recipients @@ -2076,7 +2077,7 @@ if(isset($_POST['test_campaign'])){ $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $config_smtp_username; // SMTP username $mail->Password = $config_smtp_password; // SMTP password - $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted + $mail->SMTPSecure = $config_smtp_encryption; // Enable TLS encryption, `ssl` also accepted $mail->Port = $config_smtp_port; // TCP port to connect to //Recipients @@ -3376,7 +3377,7 @@ if(isset($_GET['email_quote'])){ $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $config_smtp_username; // SMTP username $mail->Password = $config_smtp_password; // SMTP password - $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted + $mail->SMTPSecure = $config_smtp_encryption; // Enable TLS encryption, `ssl` also accepted $mail->Port = $config_smtp_port; // TCP port to connect to //Recipients @@ -3887,7 +3888,7 @@ if(isset($_POST['add_payment'])){ $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $config_smtp_username; // SMTP username $mail->Password = $config_smtp_password; // SMTP password - $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted + $mail->SMTPSecure = $config_smtp_encryption; // Enable TLS encryption, `ssl` also accepted $mail->Port = $config_smtp_port; // TCP port to connect to //Recipients @@ -3923,7 +3924,7 @@ if(isset($_POST['add_payment'])){ $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $config_smtp_username; // SMTP username $mail->Password = $config_smtp_password; // SMTP password - $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted + $mail->SMTPSecure = $config_smtp_encryption; // Enable TLS encryption, `ssl` also accepted $mail->Port = $config_smtp_port; // TCP port to connect to //Recipients @@ -4070,7 +4071,7 @@ if(isset($_GET['email_invoice'])){ $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $config_smtp_username; // SMTP username $mail->Password = $config_smtp_password; // SMTP password - $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted + $mail->SMTPSecure = $config_smtp_encryption; // Enable TLS encryption, `ssl` also accepted $mail->Port = $config_smtp_port; // TCP port to connect to //Recipients @@ -6217,7 +6218,7 @@ if(isset($_POST['add_ticket_reply'])){ $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $config_smtp_username; // SMTP username $mail->Password = $config_smtp_password; // SMTP password - $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted + $mail->SMTPSecure = $config_smtp_encryption; // Enable TLS encryption, `ssl` also accepted $mail->Port = $config_smtp_port; // TCP port to connect to //Recipients @@ -7179,7 +7180,7 @@ if(isset($_GET['force_recurring'])){ $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $config_smtp_username; // SMTP username $mail->Password = $config_smtp_password; // SMTP password - $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted + $mail->SMTPSecure = $config_smtp_encryption; // Enable TLS encryption, `ssl` also accepted $mail->Port = $config_smtp_port; // TCP port to connect to //Recipients diff --git a/settings-mail.php b/settings-mail.php index 84d4b4b9..98b5da6c 100644 --- a/settings-mail.php +++ b/settings-mail.php @@ -26,6 +26,20 @@ + +
+ +
+
+ +
+ +
+
@@ -41,7 +55,7 @@
- +