DB Structure Update - Added SMTP Encryption Type to Mail settings

This commit is contained in:
johnnyq
2022-04-02 16:03:30 -04:00
parent 32f3b0a005
commit ef29a17d49
6 changed files with 37 additions and 17 deletions

View File

@@ -24,6 +24,7 @@ while($row = mysqli_fetch_array($sql_companies)){
$config_smtp_username = $row['config_smtp_username']; $config_smtp_username = $row['config_smtp_username'];
$config_smtp_password = $row['config_smtp_password']; $config_smtp_password = $row['config_smtp_password'];
$config_smtp_port = $row['config_smtp_port']; $config_smtp_port = $row['config_smtp_port'];
$config_smtp_encryption = $row['config_smtp_encryption'];
$config_base_url = $row['config_base_url']; $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()"); $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->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $config_smtp_username; // SMTP username $mail->Username = $config_smtp_username; // SMTP username
$mail->Password = $config_smtp_password; // SMTP password $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 $mail->Port = $config_smtp_port; // TCP port to connect to
//Recipients //Recipients

View File

@@ -30,6 +30,7 @@ while($row = mysqli_fetch_array($sql_companies)){
$config_smtp_username = $row['config_smtp_username']; $config_smtp_username = $row['config_smtp_username'];
$config_smtp_password = $row['config_smtp_password']; $config_smtp_password = $row['config_smtp_password'];
$config_smtp_port = $row['config_smtp_port']; $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_email = $row['config_mail_from_email'];
$config_mail_from_name = $row['config_mail_from_name']; $config_mail_from_name = $row['config_mail_from_name'];
$config_recurring_auto_send_invoice = $row['config_recurring_auto_send_invoice']; $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->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $config_smtp_username; // SMTP username $mail->Username = $config_smtp_username; // SMTP username
$mail->Password = $config_smtp_password; // SMTP password $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 $mail->Port = $config_smtp_port; // TCP port to connect to
//Recipients //Recipients
@@ -441,7 +442,7 @@ while($row = mysqli_fetch_array($sql_companies)){
$mail->SMTPAuth = true; // Enable SMTP authentication $mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $config_smtp_username; // SMTP username $mail->Username = $config_smtp_username; // SMTP username
$mail->Password = $config_smtp_password; // SMTP password $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 $mail->Port = $config_smtp_port; // TCP port to connect to
//Recipients //Recipients

6
db.sql
View File

@@ -1,6 +1,6 @@
-- MariaDB dump 10.19 Distrib 10.5.15-MariaDB, for debian-linux-gnu (x86_64) -- 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 -- 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 */; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `settings` ( CREATE TABLE `settings` (
`company_id` int(11) NOT NULL, `company_id` int(11) NOT NULL,
`config_current_database_version` varchar(10) NOT NULL,
`config_base_url` varchar(200) DEFAULT NULL, `config_base_url` varchar(200) DEFAULT NULL,
`config_smtp_host` varchar(200) DEFAULT NULL, `config_smtp_host` varchar(200) DEFAULT NULL,
`config_smtp_port` int(5) 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_username` varchar(200) DEFAULT NULL,
`config_smtp_password` varchar(200) DEFAULT NULL, `config_smtp_password` varchar(200) DEFAULT NULL,
`config_mail_from_email` 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 */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!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

View File

@@ -19,6 +19,7 @@ $config_azure_client_secret = $row['config_azure_client_secret'];
// Mail // Mail
$config_smtp_host = $row['config_smtp_host']; $config_smtp_host = $row['config_smtp_host'];
$config_smtp_port = $row['config_smtp_port']; $config_smtp_port = $row['config_smtp_port'];
$config_smtp_encryption = $row['config_smtp_encryption'];
$config_smtp_username = $row['config_smtp_username']; $config_smtp_username = $row['config_smtp_username'];
$config_smtp_password = $row['config_smtp_password']; $config_smtp_password = $row['config_smtp_password'];
$config_mail_from_email = $row['config_mail_from_email']; $config_mail_from_email = $row['config_mail_from_email'];

View File

@@ -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_host = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_smtp_host'])));
$config_smtp_port = intval($_POST['config_smtp_port']); $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_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_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_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']))); $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 //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->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $config_smtp_username; // SMTP username $mail->Username = $config_smtp_username; // SMTP username
$mail->Password = $config_smtp_password; // SMTP password $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 $mail->Port = $config_smtp_port; // TCP port to connect to
//Recipients //Recipients
@@ -1604,7 +1605,7 @@ if(isset($_POST['add_event'])){
$mail->SMTPAuth = true; // Enable SMTP authentication $mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $config_smtp_username; // SMTP username $mail->Username = $config_smtp_username; // SMTP username
$mail->Password = $config_smtp_password; // SMTP password $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 $mail->Port = $config_smtp_port; // TCP port to connect to
//Recipients //Recipients
@@ -1681,7 +1682,7 @@ if(isset($_POST['edit_event'])){
$mail->SMTPAuth = true; // Enable SMTP authentication $mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $config_smtp_username; // SMTP username $mail->Username = $config_smtp_username; // SMTP username
$mail->Password = $config_smtp_password; // SMTP password $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 $mail->Port = $config_smtp_port; // TCP port to connect to
//Recipients //Recipients
@@ -2076,7 +2077,7 @@ if(isset($_POST['test_campaign'])){
$mail->SMTPAuth = true; // Enable SMTP authentication $mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $config_smtp_username; // SMTP username $mail->Username = $config_smtp_username; // SMTP username
$mail->Password = $config_smtp_password; // SMTP password $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 $mail->Port = $config_smtp_port; // TCP port to connect to
//Recipients //Recipients
@@ -3376,7 +3377,7 @@ if(isset($_GET['email_quote'])){
$mail->SMTPAuth = true; // Enable SMTP authentication $mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $config_smtp_username; // SMTP username $mail->Username = $config_smtp_username; // SMTP username
$mail->Password = $config_smtp_password; // SMTP password $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 $mail->Port = $config_smtp_port; // TCP port to connect to
//Recipients //Recipients
@@ -3887,7 +3888,7 @@ if(isset($_POST['add_payment'])){
$mail->SMTPAuth = true; // Enable SMTP authentication $mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $config_smtp_username; // SMTP username $mail->Username = $config_smtp_username; // SMTP username
$mail->Password = $config_smtp_password; // SMTP password $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 $mail->Port = $config_smtp_port; // TCP port to connect to
//Recipients //Recipients
@@ -3923,7 +3924,7 @@ if(isset($_POST['add_payment'])){
$mail->SMTPAuth = true; // Enable SMTP authentication $mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $config_smtp_username; // SMTP username $mail->Username = $config_smtp_username; // SMTP username
$mail->Password = $config_smtp_password; // SMTP password $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 $mail->Port = $config_smtp_port; // TCP port to connect to
//Recipients //Recipients
@@ -4070,7 +4071,7 @@ if(isset($_GET['email_invoice'])){
$mail->SMTPAuth = true; // Enable SMTP authentication $mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $config_smtp_username; // SMTP username $mail->Username = $config_smtp_username; // SMTP username
$mail->Password = $config_smtp_password; // SMTP password $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 $mail->Port = $config_smtp_port; // TCP port to connect to
//Recipients //Recipients
@@ -6217,7 +6218,7 @@ if(isset($_POST['add_ticket_reply'])){
$mail->SMTPAuth = true; // Enable SMTP authentication $mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $config_smtp_username; // SMTP username $mail->Username = $config_smtp_username; // SMTP username
$mail->Password = $config_smtp_password; // SMTP password $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 $mail->Port = $config_smtp_port; // TCP port to connect to
//Recipients //Recipients
@@ -7179,7 +7180,7 @@ if(isset($_GET['force_recurring'])){
$mail->SMTPAuth = true; // Enable SMTP authentication $mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $config_smtp_username; // SMTP username $mail->Username = $config_smtp_username; // SMTP username
$mail->Password = $config_smtp_password; // SMTP password $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 $mail->Port = $config_smtp_port; // TCP port to connect to
//Recipients //Recipients

View File

@@ -26,6 +26,20 @@
<input type="number" min="0" class="form-control" name="config_smtp_port" placeholder="Mail Server Port Number" value="<?php echo $config_smtp_port; ?>" required> <input type="number" min="0" class="form-control" name="config_smtp_port" placeholder="Mail Server Port Number" value="<?php echo $config_smtp_port; ?>" required>
</div> </div>
</div> </div>
<div class="form-group">
<label>Encryption</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-lock"></i></span>
</div>
<select class="form-control" name="config_smtp_encryption">
<option value=''>None</option>
<option <?php if($config_smtp_encryption == 'tls'){ echo "selected"; } ?>>tls</option>
<option <?php if($config_smtp_encryption == 'ssl'){ echo "selected"; } ?>>ssl</option>
</select>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label>SMTP Username</label> <label>SMTP Username</label>
@@ -41,7 +55,7 @@
<label>SMTP Password</label> <label>SMTP Password</label>
<div class="input-group"> <div class="input-group">
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-lock"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-key"></i></span>
</div> </div>
<input type="password" class="form-control" data-toggle="password" name="config_smtp_password" placeholder="Password" value="<?php echo $config_smtp_password; ?>" autocomplete="new-password" required> <input type="password" class="form-control" data-toggle="password" name="config_smtp_password" placeholder="Password" value="<?php echo $config_smtp_password; ?>" autocomplete="new-password" required>
<div class="input-group-append"> <div class="input-group-append">