mirror of https://github.com/itflow-org/itflow
Reworked mail settings to include all mail related thing to be in one spot and easy to understand Also updated test email to test email from each email from address configured
This commit is contained in:
parent
0377eeb94e
commit
597b7575d6
|
|
@ -59,37 +59,9 @@ if (isset($_POST['edit_mail_smtp_settings'])) {
|
|||
$config_smtp_encryption = sanitizeInput($_POST['config_smtp_encryption']);
|
||||
$config_smtp_username = sanitizeInput($_POST['config_smtp_username']);
|
||||
$config_smtp_password = sanitizeInput($_POST['config_smtp_password']);
|
||||
$config_mail_from_email = sanitizeInput($_POST['config_mail_from_email']);
|
||||
$config_mail_from_name = sanitizeInput($_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_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 = 1");
|
||||
|
||||
|
||||
//Update From Email and From Name if Invoice/Quote or Ticket fields are blank
|
||||
if (empty($config_invoice_from_name)) {
|
||||
mysqli_query($mysqli,"UPDATE settings SET config_invoice_from_name = '$config_mail_from_name' WHERE company_id = 1");
|
||||
}
|
||||
|
||||
if (empty($config_invoice_from_email)) {
|
||||
mysqli_query($mysqli,"UPDATE settings SET config_invoice_from_email = '$config_mail_from_email' WHERE company_id = 1");
|
||||
}
|
||||
|
||||
if (empty($config_quote_from_name)) {
|
||||
mysqli_query($mysqli,"UPDATE settings SET config_quote_from_name = '$config_mail_from_name' WHERE company_id = 1");
|
||||
}
|
||||
|
||||
if (empty($config_quote_from_email)) {
|
||||
mysqli_query($mysqli,"UPDATE settings SET config_quote_from_email = '$config_mail_from_email' WHERE company_id = 1");
|
||||
}
|
||||
|
||||
if (empty($config_ticket_from_name)) {
|
||||
mysqli_query($mysqli,"UPDATE settings SET config_ticket_from_name = '$config_mail_from_name' WHERE company_id = 1");
|
||||
}
|
||||
|
||||
if (empty($config_ticket_from_email)) {
|
||||
mysqli_query($mysqli,"UPDATE settings SET config_ticket_from_email = '$config_mail_from_email' WHERE company_id = 1");
|
||||
}
|
||||
|
||||
// Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Settings', log_action = 'Modify', log_description = '$session_name modified SMTP mail settings', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
|
||||
|
||||
|
|
@ -121,17 +93,44 @@ if (isset($_POST['edit_mail_imap_settings'])) {
|
|||
|
||||
}
|
||||
|
||||
if (isset($_POST['test_email_smtp'])) {
|
||||
if (isset($_POST['edit_mail_from_settings'])) {
|
||||
|
||||
validateAdminRole();
|
||||
|
||||
$email = sanitizeInput($_POST['email']);
|
||||
$config_mail_from_email = sanitizeInput($_POST['config_mail_from_email']);
|
||||
$config_mail_from_name = sanitizeInput($_POST['config_mail_from_name']);
|
||||
|
||||
$config_invoice_from_email = sanitizeInput($_POST['config_invoice_from_email']);
|
||||
$config_invoice_from_name = sanitizeInput($_POST['config_invoice_from_name']);
|
||||
|
||||
$config_quote_from_email = sanitizeInput($_POST['config_quote_from_email']);
|
||||
$config_quote_from_name = sanitizeInput($_POST['config_quote_from_name']);
|
||||
|
||||
$config_ticket_from_email = sanitizeInput($_POST['config_ticket_from_email']);
|
||||
$config_ticket_from_name = sanitizeInput($_POST['config_ticket_from_name']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE settings SET config_mail_from_email = '$config_mail_from_email', config_mail_from_name = '$config_mail_from_name', config_invoice_from_email = '$config_invoice_from_email', config_invoice_from_name = '$config_invoice_from_name', config_quote_from_email = '$config_quote_from_email', config_quote_from_name = '$config_quote_from_name', config_ticket_from_email = '$config_ticket_from_email', config_ticket_from_name = '$config_ticket_from_name' WHERE company_id = 1");
|
||||
|
||||
// Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Settings', log_action = 'Modify', log_description = '$session_name modified Mail From settings', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Mail From Settings updated";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
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";
|
||||
|
||||
$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, $email,
|
||||
$email_from, $config_mail_from_name,
|
||||
$email_to, $email_to,
|
||||
$subject, $body);
|
||||
|
||||
if ($mail === true) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ require_once("inc_all_settings.php"); ?>
|
|||
|
||||
<div class="card card-dark">
|
||||
<div class="card-header py-3">
|
||||
<h3 class="card-title"><i class="fas fa-fw fa-envelope mr-2"></i>SMTP Mail Settings</h3>
|
||||
<h3 class="card-title"><i class="fas fa-fw fa-envelope mr-2"></i>SMTP Mail Settings <small>(For Sending Email)</small></h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
|
|
@ -65,26 +65,6 @@ require_once("inc_all_settings.php"); ?>
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Email Address</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-envelope"></i></span>
|
||||
</div>
|
||||
<input type="email" class="form-control" name="config_mail_from_email" placeholder="Email Address" value="<?php echo nullable_htmlentities($config_mail_from_email); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Name</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="config_mail_from_name" placeholder="Name" value="<?php echo nullable_htmlentities($config_mail_from_name); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<button type="submit" name="edit_mail_smtp_settings" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Save</button>
|
||||
|
|
@ -95,7 +75,7 @@ require_once("inc_all_settings.php"); ?>
|
|||
|
||||
<div class="card card-dark">
|
||||
<div class="card-header py-3">
|
||||
<h3 class="card-title"><i class="fas fa-fw fa-envelope mr-2"></i>IMAP Mail Settings</h3>
|
||||
<h3 class="card-title"><i class="fas fa-fw fa-envelope mr-2"></i>IMAP Mail Settings <small>(For Monitoring Ticket Inbox)</small></h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
|
|
@ -167,6 +147,112 @@ require_once("inc_all_settings.php"); ?>
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card card-dark">
|
||||
<div class="card-header py-3">
|
||||
<h3 class="card-title"><i class="fas fa-fw fa-envelope mr-2"></i>Mail From Configuration</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<p>Each of the "From Email" Addresses need to be able to send email on behalf of the SMTP user configured above
|
||||
<h3>Generic</h3>
|
||||
<p>(used for system tasks such as sending share links)</p>
|
||||
<div class="form-group">
|
||||
<label>From Email</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-envelope"></i></span>
|
||||
</div>
|
||||
<input type="email" class="form-control" name="config_mail_from_email" placeholder="Email Address (ex noreply@yourcompany.com)" value="<?php echo nullable_htmlentities($config_mail_from_email); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>From Name</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="config_mail_from_name" placeholder="Name (ex YourCompany)" value="<?php echo nullable_htmlentities($config_mail_from_name); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>Invoices</h3>
|
||||
<p>(used for when invoice emails are sent)</p>
|
||||
|
||||
<div class="form-group">
|
||||
<label>From Email</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-envelope"></i></span>
|
||||
</div>
|
||||
<input type="email" class="form-control" name="config_invoice_from_email" placeholder="Email (ex billing@yourcompany.com)" value="<?php echo nullable_htmlentities($config_invoice_from_email); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>From Name</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="config_invoice_from_name" placeholder="Name (ex CompanyName Billing)" value="<?php echo nullable_htmlentities($config_invoice_from_name); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>Quotes</h3>
|
||||
<p>(used for when quote emails are sent)</p>
|
||||
|
||||
<div class="form-group">
|
||||
<label>From Email</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-envelope"></i></span>
|
||||
</div>
|
||||
<input type="email" class="form-control" name="config_quote_from_email" placeholder="Email (ex sales@yourcompany.com)" value="<?php echo nullable_htmlentities($config_quote_from_email); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>From Name</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="config_quote_from_name" placeholder="Name (ex YourCompany Sales)" value="<?php echo nullable_htmlentities($config_quote_from_name); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>Tickets</h3>
|
||||
<p>(used for when tickets are created and emailed to a client)</p>
|
||||
|
||||
<div class="form-group">
|
||||
<label>From Email</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-envelope"></i></span>
|
||||
</div>
|
||||
<input type="email" class="form-control" name="config_ticket_from_email" placeholder="Email (ex support@yourcompany.com)" value="<?php echo nullable_htmlentities($config_ticket_from_email); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>From Name</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="config_ticket_from_name" placeholder="Name (ex YourCompany Support)" value="<?php echo nullable_htmlentities($config_ticket_from_name); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<button type="submit" name="edit_mail_from_settings" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Save</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($config_smtp_host) && !empty($config_smtp_port) && !empty($config_mail_from_email) && !empty($config_mail_from_name)) { ?>
|
||||
|
||||
<div class="card card-dark">
|
||||
|
|
@ -176,7 +262,33 @@ require_once("inc_all_settings.php"); ?>
|
|||
<div class="card-body">
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<div class="input-group">
|
||||
<input type="email" class="form-control " name="email" placeholder="Email address to test">
|
||||
<select class="form-control select2" name="email_from" required>
|
||||
<option value="">- Select an Email Address to send from -</option>
|
||||
<?php
|
||||
if(!empty($config_mail_from_email)){
|
||||
?>
|
||||
<option><?php echo nullable_htmlentities($config_mail_from_email); ?></option>
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
if(!empty($config_ticket_from_email)){
|
||||
?>
|
||||
<option><?php echo nullable_htmlentities($config_ticket_from_email); ?></option>
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
if(!empty($config_invoice_from_email)){
|
||||
?>
|
||||
<option><?php echo nullable_htmlentities($config_invoice_from_email); ?></option>
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
if(!empty($config_quote_from_email)){
|
||||
?>
|
||||
<option><?php echo nullable_htmlentities($config_quote_from_email); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<input type="email" class="form-control " name="email_to" placeholder="Email address to send to">
|
||||
<div class="input-group-append">
|
||||
<button type="submit" name="test_email_smtp" class="btn btn-success"><i class="fas fa-fw fa-paper-plane mr-2"></i>Send</button>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue