Added a test Email Functionality Section under settings - General - Mail

This commit is contained in:
johnny@pittpc.com 2021-02-08 22:02:01 -05:00
parent fa008d05bc
commit 5e2c016633
2 changed files with 55 additions and 0 deletions

View File

@ -386,6 +386,47 @@ if(isset($_POST['edit_mail_settings'])){
}
if(isset($_POST['test_email'])){
$email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']));
$mail = new PHPMailer(true);
try{
//Mail Server Settings
//$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = $config_smtp_host; // Specify main and backup SMTP servers
$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->Port = $config_smtp_port; // TCP port to connect to
//Recipients
$mail->setFrom($config_mail_from_email, $config_mail_from_name);
$mail->addAddress("$email"); // Add a recipient
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = "Hi'ya there Chap";
$mail->Body = "Hello there Chap ;) Don't worry this won't hurt a bit, it's just a test. ${$email}";
$mail->send();
echo 'Message has been sent';
$_SESSION['alert_message'] = "Test Email has been sent!";
header("Location: " . $_SERVER["HTTP_REFERER"]);
} catch (Exception $e) {
echo "poop";
}
}
if(isset($_POST['edit_invoice_quote_settings'])){
$config_invoice_prefix = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_invoice_prefix']));

View File

@ -77,4 +77,18 @@
</div>
</div>
<div class="card card-dark">
<div class="card-header">
<h3 class="card-title"><i class="fa fa-fw fa-paper-plane"></i> Test Email</h3>
</div>
<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">
<div class="input-group-append">
<button type="submit" name="test_email" class="btn btn-secondary"><i class="fa fa-fw fa-paper-plane"></i> Send</button>
</div>
</div>
</form>
<?php include("footer.php");