feat: allow selecting tls or ssl for email notifications (#237)
This commit is contained in:
parent
e1cc9254ac
commit
2462435743
@ -14,6 +14,7 @@
|
|||||||
$days = $row['days'];
|
$days = $row['days'];
|
||||||
$smtpAddress = $row["smtp_address"];
|
$smtpAddress = $row["smtp_address"];
|
||||||
$smtpPort = $row["smtp_port"];
|
$smtpPort = $row["smtp_port"];
|
||||||
|
$encryption = $row["encryption"];
|
||||||
$smtpUsername = $row["smtp_username"];
|
$smtpUsername = $row["smtp_username"];
|
||||||
$smtpPassword = $row["smtp_password"];
|
$smtpPassword = $row["smtp_password"];
|
||||||
$fromEmail = $row["from_email"] ? $row["from_email"] : "wallos@wallosapp.com";
|
$fromEmail = $row["from_email"] ? $row["from_email"] : "wallos@wallosapp.com";
|
||||||
@ -76,7 +77,7 @@
|
|||||||
$mail->SMTPAuth = true;
|
$mail->SMTPAuth = true;
|
||||||
$mail->Username = $smtpUsername;
|
$mail->Username = $smtpUsername;
|
||||||
$mail->Password = $smtpPassword;
|
$mail->Password = $smtpPassword;
|
||||||
$mail->SMTPSecure = 'tls';
|
$mail->SMTPSecure = $encryption;
|
||||||
$mail->Port = $smtpPort;
|
$mail->Port = $smtpPort;
|
||||||
|
|
||||||
$stmt = $db->prepare('SELECT * FROM household WHERE id = :userId');
|
$stmt = $db->prepare('SELECT * FROM household WHERE id = :userId');
|
||||||
|
|||||||
@ -23,6 +23,10 @@
|
|||||||
$days = $data["days"];
|
$days = $data["days"];
|
||||||
$smtpAddress = $data["smtpaddress"];
|
$smtpAddress = $data["smtpaddress"];
|
||||||
$smtpPort = $data["smtpport"];
|
$smtpPort = $data["smtpport"];
|
||||||
|
$encryption = "tls";
|
||||||
|
if (isset($data["encryption"])) {
|
||||||
|
$encryption = $data["encryption"];
|
||||||
|
}
|
||||||
$smtpUsername = $data["smtpusername"];
|
$smtpUsername = $data["smtpusername"];
|
||||||
$smtpPassword = $data["smtppassword"];
|
$smtpPassword = $data["smtppassword"];
|
||||||
$fromEmail = $data["fromemail"];
|
$fromEmail = $data["fromemail"];
|
||||||
@ -38,12 +42,12 @@
|
|||||||
echo json_encode($response);
|
echo json_encode($response);
|
||||||
} else {
|
} else {
|
||||||
if ($result == 0) {
|
if ($result == 0) {
|
||||||
$query = "INSERT INTO notifications (enabled, days, smtp_address, smtp_port, smtp_username, smtp_password, from_email)
|
$query = "INSERT INTO notifications (enabled, days, smtp_address, smtp_port, smtp_username, smtp_password, from_email, encryption)
|
||||||
VALUES (:enabled, :days, :smtpAddress, :smtpPort, :smtpUsername, :smtpPassword, :fromEmail)";
|
VALUES (:enabled, :days, :smtpAddress, :smtpPort, :smtpUsername, :smtpPassword, :fromEmail, :encryption)";
|
||||||
} else {
|
} else {
|
||||||
$query = "UPDATE notifications
|
$query = "UPDATE notifications
|
||||||
SET enabled = :enabled, days = :days, smtp_address = :smtpAddress, smtp_port = :smtpPort,
|
SET enabled = :enabled, days = :days, smtp_address = :smtpAddress, smtp_port = :smtpPort,
|
||||||
smtp_username = :smtpUsername, smtp_password = :smtpPassword, from_email = :fromEmail";
|
smtp_username = :smtpUsername, smtp_password = :smtpPassword, from_email = :fromEmail, encryption = :encryption";
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = $db->prepare($query);
|
$stmt = $db->prepare($query);
|
||||||
@ -54,6 +58,7 @@
|
|||||||
$stmt->bindValue(':smtpUsername', $smtpUsername, SQLITE3_TEXT);
|
$stmt->bindValue(':smtpUsername', $smtpUsername, SQLITE3_TEXT);
|
||||||
$stmt->bindValue(':smtpPassword', $smtpPassword, SQLITE3_TEXT);
|
$stmt->bindValue(':smtpPassword', $smtpPassword, SQLITE3_TEXT);
|
||||||
$stmt->bindValue(':fromEmail', $fromEmail, SQLITE3_TEXT);
|
$stmt->bindValue(':fromEmail', $fromEmail, SQLITE3_TEXT);
|
||||||
|
$stmt->bindValue(':encryption', $encryption, SQLITE3_TEXT);
|
||||||
|
|
||||||
if ($stmt->execute()) {
|
if ($stmt->execute()) {
|
||||||
$response = [
|
$response = [
|
||||||
|
|||||||
@ -23,6 +23,12 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
];
|
];
|
||||||
echo json_encode($response);
|
echo json_encode($response);
|
||||||
} else {
|
} else {
|
||||||
|
$enxryption = "tls";
|
||||||
|
if (isset($data["encryption"])) {
|
||||||
|
$encryption = $data["encryption"];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
require '../../libs/PHPMailer/PHPMailer.php';
|
require '../../libs/PHPMailer/PHPMailer.php';
|
||||||
require '../../libs/PHPMailer/SMTP.php';
|
require '../../libs/PHPMailer/SMTP.php';
|
||||||
require '../../libs/PHPMailer/Exception.php';
|
require '../../libs/PHPMailer/Exception.php';
|
||||||
@ -41,7 +47,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
$mail->SMTPAuth = true;
|
$mail->SMTPAuth = true;
|
||||||
$mail->Username = $smtpUsername;
|
$mail->Username = $smtpUsername;
|
||||||
$mail->Password = $smtpPassword;
|
$mail->Password = $smtpPassword;
|
||||||
$mail->SMTPSecure = 'tls';
|
$mail->SMTPSecure = $encryption;
|
||||||
$mail->Port = $smtpPort;
|
$mail->Port = $smtpPort;
|
||||||
|
|
||||||
$getUser = "SELECT * FROM user WHERE id = 1";
|
$getUser = "SELECT * FROM user WHERE id = 1";
|
||||||
|
|||||||
@ -111,6 +111,8 @@ $i18n = [
|
|||||||
"days_before" => "Tage bevor",
|
"days_before" => "Tage bevor",
|
||||||
"smtp_address" => "SMTP Adresse",
|
"smtp_address" => "SMTP Adresse",
|
||||||
"port" => "Port",
|
"port" => "Port",
|
||||||
|
"tls" => "TLS",
|
||||||
|
"ssl" => "SSL",
|
||||||
"smtp_username" => "SMTP Benutzername",
|
"smtp_username" => "SMTP Benutzername",
|
||||||
"smtp_password" => "SMTP Passwort",
|
"smtp_password" => "SMTP Passwort",
|
||||||
"from_email" => "Absender E-Mail Adresse (optional)",
|
"from_email" => "Absender E-Mail Adresse (optional)",
|
||||||
|
|||||||
@ -111,6 +111,8 @@ $i18n = [
|
|||||||
"days_before" => "ημέρες πριν",
|
"days_before" => "ημέρες πριν",
|
||||||
"smtp_address" => "SMTP Address",
|
"smtp_address" => "SMTP Address",
|
||||||
"port" => "Θύρα",
|
"port" => "Θύρα",
|
||||||
|
"tls" => "TLS",
|
||||||
|
"ssl" => "SSL",
|
||||||
"smtp_username" => "SMTP χρήστης",
|
"smtp_username" => "SMTP χρήστης",
|
||||||
"smtp_password" => "SMTP κωδικός",
|
"smtp_password" => "SMTP κωδικός",
|
||||||
"from_email" => "Από (Προαιρετικό)",
|
"from_email" => "Από (Προαιρετικό)",
|
||||||
|
|||||||
@ -111,6 +111,8 @@ $i18n = [
|
|||||||
"days_before" => "days before",
|
"days_before" => "days before",
|
||||||
"smtp_address" => "SMTP Address",
|
"smtp_address" => "SMTP Address",
|
||||||
"port" => "Port",
|
"port" => "Port",
|
||||||
|
"tls" => "TLS",
|
||||||
|
"ssl" => "SSL",
|
||||||
"smtp_username" => "SMTP Username",
|
"smtp_username" => "SMTP Username",
|
||||||
"smtp_password" => "SMTP Password",
|
"smtp_password" => "SMTP Password",
|
||||||
"from_email" => "From email (Optional)",
|
"from_email" => "From email (Optional)",
|
||||||
|
|||||||
@ -111,6 +111,8 @@ $i18n = [
|
|||||||
"days_before" => "días antes",
|
"days_before" => "días antes",
|
||||||
"smtp_address" => "Dirección SMTP",
|
"smtp_address" => "Dirección SMTP",
|
||||||
"port" => "Puerto",
|
"port" => "Puerto",
|
||||||
|
"tls" => "TLS",
|
||||||
|
"ssl" => "SSL",
|
||||||
"smtp_username" => "Nombre de usuario SMTP",
|
"smtp_username" => "Nombre de usuario SMTP",
|
||||||
"smtp_password" => "Contraseña SMTP",
|
"smtp_password" => "Contraseña SMTP",
|
||||||
"from_email" => "Correo electrónico de origen (Opcional)",
|
"from_email" => "Correo electrónico de origen (Opcional)",
|
||||||
|
|||||||
@ -111,6 +111,8 @@ $i18n = [
|
|||||||
"days_before" => "jours avant",
|
"days_before" => "jours avant",
|
||||||
"smtp_address" => "Adresse SMTP",
|
"smtp_address" => "Adresse SMTP",
|
||||||
"port" => "Port",
|
"port" => "Port",
|
||||||
|
"tls" => "TLS",
|
||||||
|
"ssl" => "SSL",
|
||||||
"smtp_username" => "Nom d'utilisateur SMTP",
|
"smtp_username" => "Nom d'utilisateur SMTP",
|
||||||
"smtp_password" => "Mot de passe SMTP",
|
"smtp_password" => "Mot de passe SMTP",
|
||||||
"from_email" => "De l'adresse courriel (facultatif)",
|
"from_email" => "De l'adresse courriel (facultatif)",
|
||||||
|
|||||||
@ -111,6 +111,8 @@ $i18n = [
|
|||||||
"days_before" => "日前",
|
"days_before" => "日前",
|
||||||
"smtp_address" => "SMTPアドレス",
|
"smtp_address" => "SMTPアドレス",
|
||||||
"port" => "ポート番号",
|
"port" => "ポート番号",
|
||||||
|
"tls" => "TLS",
|
||||||
|
"ssl" => "SSL",
|
||||||
"smtp_username" => "SMTPユーザー名",
|
"smtp_username" => "SMTPユーザー名",
|
||||||
"smtp_password" => "SMTPパスワード",
|
"smtp_password" => "SMTPパスワード",
|
||||||
"from_email" => "送信元アドレス (オプション)",
|
"from_email" => "送信元アドレス (オプション)",
|
||||||
|
|||||||
@ -111,6 +111,8 @@ $i18n = [
|
|||||||
"days_before" => "dias antes",
|
"days_before" => "dias antes",
|
||||||
"smtp_address" => "Endereço SMTP",
|
"smtp_address" => "Endereço SMTP",
|
||||||
"port" => "Porto",
|
"port" => "Porto",
|
||||||
|
"tls" => "TLS",
|
||||||
|
"ssl" => "SSL",
|
||||||
"smtp_username" => "Utilizador SMTP",
|
"smtp_username" => "Utilizador SMTP",
|
||||||
"smtp_password" => "Password SMTP",
|
"smtp_password" => "Password SMTP",
|
||||||
"from_email" => "Email de envio (Opcional)",
|
"from_email" => "Email de envio (Opcional)",
|
||||||
|
|||||||
@ -109,6 +109,8 @@ $i18n = [
|
|||||||
"days_before" => "dias antes",
|
"days_before" => "dias antes",
|
||||||
"smtp_address" => "Endereço SMTP",
|
"smtp_address" => "Endereço SMTP",
|
||||||
"port" => "Porta",
|
"port" => "Porta",
|
||||||
|
"tls" => "TLS",
|
||||||
|
"ssl" => "SSL",
|
||||||
"smtp_username" => "Usuário SMTP",
|
"smtp_username" => "Usuário SMTP",
|
||||||
"smtp_password" => "Senha SMTP",
|
"smtp_password" => "Senha SMTP",
|
||||||
"from_email" => "Email de envio (Opcional)",
|
"from_email" => "Email de envio (Opcional)",
|
||||||
|
|||||||
@ -111,6 +111,8 @@ $i18n = [
|
|||||||
"days_before" => "günler önce",
|
"days_before" => "günler önce",
|
||||||
"smtp_address" => "SMTP Adresi",
|
"smtp_address" => "SMTP Adresi",
|
||||||
"port" => "Port",
|
"port" => "Port",
|
||||||
|
"tls" => "TLS",
|
||||||
|
"ssl" => "SSL",
|
||||||
"smtp_username" => "SMTP Kullanıcı Adı",
|
"smtp_username" => "SMTP Kullanıcı Adı",
|
||||||
"smtp_password" => "SMTP Şifresi",
|
"smtp_password" => "SMTP Şifresi",
|
||||||
"from_email" => "Gönderen e-posta (İsteğe bağlı)",
|
"from_email" => "Gönderen e-posta (İsteğe bağlı)",
|
||||||
|
|||||||
@ -118,6 +118,8 @@ $i18n = [
|
|||||||
"days_before" => "天",
|
"days_before" => "天",
|
||||||
"smtp_address" => "SMTP 地址",
|
"smtp_address" => "SMTP 地址",
|
||||||
"port" => "端口",
|
"port" => "端口",
|
||||||
|
"tls" => "TLS",
|
||||||
|
"ssl" => "SSL",
|
||||||
"smtp_username" => "SMTP 用户名",
|
"smtp_username" => "SMTP 用户名",
|
||||||
"smtp_password" => "SMTP 密码",
|
"smtp_password" => "SMTP 密码",
|
||||||
"from_email" => "发件人邮箱(可选)",
|
"from_email" => "发件人邮箱(可选)",
|
||||||
|
|||||||
@ -111,6 +111,8 @@ $i18n = [
|
|||||||
"days_before" => "天",
|
"days_before" => "天",
|
||||||
"smtp_address" => "SMTP 信箱地址",
|
"smtp_address" => "SMTP 信箱地址",
|
||||||
"port" => "連接埠",
|
"port" => "連接埠",
|
||||||
|
"tls" => "TLS",
|
||||||
|
"ssl" => "SSL",
|
||||||
"smtp_username" => "SMTP 使用者名稱",
|
"smtp_username" => "SMTP 使用者名稱",
|
||||||
"smtp_password" => "SMTP 密碼",
|
"smtp_password" => "SMTP 密碼",
|
||||||
"from_email" => "寄件人信箱(可選)",
|
"from_email" => "寄件人信箱(可選)",
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
<?php
|
<?php
|
||||||
$version = "v1.16.3";
|
$version = "v1.17.0";
|
||||||
?>
|
?>
|
||||||
12
migrations/000012.php
Normal file
12
migrations/000012.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
// This migration adds a "encryption" column to the notifications table so that the encryption type can be stored.
|
||||||
|
|
||||||
|
/** @noinspection PhpUndefinedVariableInspection */
|
||||||
|
$columnQuery = $db->query("SELECT * FROM pragma_table_info('notifications') WHERE name='encryption'");
|
||||||
|
$columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) === false;
|
||||||
|
|
||||||
|
if ($columnRequired) {
|
||||||
|
$db->exec('ALTER TABLE notifications ADD COLUMN `encryption` TEXT DEFAULT "tls"');
|
||||||
|
$db->exec('UPDATE notifications SET `encryption` = "tls"');
|
||||||
|
}
|
||||||
|
?>
|
||||||
@ -801,6 +801,7 @@ function saveNotificationsButton() {
|
|||||||
const days = document.getElementById("days").value;
|
const days = document.getElementById("days").value;
|
||||||
const smtpAddress = document.getElementById("smtpaddress").value;
|
const smtpAddress = document.getElementById("smtpaddress").value;
|
||||||
const smtpPort = document.getElementById("smtpport").value;
|
const smtpPort = document.getElementById("smtpport").value;
|
||||||
|
const encryption = document.querySelector('input[name="encryption"]:checked').value;
|
||||||
const smtpUsername = document.getElementById("smtpusername").value;
|
const smtpUsername = document.getElementById("smtpusername").value;
|
||||||
const smtpPassword = document.getElementById("smtppassword").value;
|
const smtpPassword = document.getElementById("smtppassword").value;
|
||||||
const fromEmail = document.getElementById("fromemail").value;
|
const fromEmail = document.getElementById("fromemail").value;
|
||||||
@ -810,6 +811,7 @@ function saveNotificationsButton() {
|
|||||||
days: days,
|
days: days,
|
||||||
smtpaddress: smtpAddress,
|
smtpaddress: smtpAddress,
|
||||||
smtpport: smtpPort,
|
smtpport: smtpPort,
|
||||||
|
encryption: encryption,
|
||||||
smtpusername: smtpUsername,
|
smtpusername: smtpUsername,
|
||||||
smtppassword: smtpPassword,
|
smtppassword: smtpPassword,
|
||||||
fromemail: fromEmail
|
fromemail: fromEmail
|
||||||
@ -843,6 +845,7 @@ function testNotificationButton() {
|
|||||||
|
|
||||||
const smtpAddress = document.getElementById("smtpaddress").value;
|
const smtpAddress = document.getElementById("smtpaddress").value;
|
||||||
const smtpPort = document.getElementById("smtpport").value;
|
const smtpPort = document.getElementById("smtpport").value;
|
||||||
|
const encryption = document.querySelector('input[name="encryption"]:checked').value;
|
||||||
const smtpUsername = document.getElementById("smtpusername").value;
|
const smtpUsername = document.getElementById("smtpusername").value;
|
||||||
const smtpPassword = document.getElementById("smtppassword").value;
|
const smtpPassword = document.getElementById("smtppassword").value;
|
||||||
const fromEmail = document.getElementById("fromemail").value;
|
const fromEmail = document.getElementById("fromemail").value;
|
||||||
@ -850,6 +853,7 @@ function testNotificationButton() {
|
|||||||
const data = {
|
const data = {
|
||||||
smtpaddress: smtpAddress,
|
smtpaddress: smtpAddress,
|
||||||
smtpport: smtpPort,
|
smtpport: smtpPort,
|
||||||
|
encryption: encryption,
|
||||||
smtpusername: smtpUsername,
|
smtpusername: smtpUsername,
|
||||||
smtppassword: smtpPassword,
|
smtppassword: smtpPassword,
|
||||||
fromemail: fromEmail
|
fromemail: fromEmail
|
||||||
|
|||||||
@ -184,6 +184,7 @@
|
|||||||
$notifications['smtp_username'] = "";
|
$notifications['smtp_username'] = "";
|
||||||
$notifications['smtp_password'] = "";
|
$notifications['smtp_password'] = "";
|
||||||
$notifications['from_email'] = "";
|
$notifications['from_email'] = "";
|
||||||
|
$notifications['encryption'] = "tls";
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@ -217,6 +218,12 @@
|
|||||||
<input type="text" name="smtpaddress" id="smtpaddress" placeholder="<?= translate('smtp_address', $i18n) ?>" value="<?= $notifications['smtp_address'] ?>" />
|
<input type="text" name="smtpaddress" id="smtpaddress" placeholder="<?= translate('smtp_address', $i18n) ?>" value="<?= $notifications['smtp_address'] ?>" />
|
||||||
<input type="text" name="smtpport" id="smtpport" placeholder="<?= translate('port', $i18n) ?>" class="one-third" value="<?= $notifications['smtp_port'] ?>" />
|
<input type="text" name="smtpport" id="smtpport" placeholder="<?= translate('port', $i18n) ?>" class="one-third" value="<?= $notifications['smtp_port'] ?>" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group-inline">
|
||||||
|
<input type="radio" name="encryption" id="encryptiontls" value="tls" <?= $notifications['encryption'] == "tls" ? "checked" : "" ?> />
|
||||||
|
<label for="encryptiontls"><?= translate('tls', $i18n) ?></label>
|
||||||
|
<input type="radio" name="encryption" id="encryptionssl" value="ssl" <?= $notifications['encryption'] == "ssl" ? "checked" : "" ?> />
|
||||||
|
<label for="encryptionssl"><?= translate('ssl', $i18n) ?></label>
|
||||||
|
</div>
|
||||||
<div class="form-group-inline">
|
<div class="form-group-inline">
|
||||||
<input type="text" name="smtpusername" id="smtpusername" placeholder="<?= translate('smtp_username', $i18n) ?>" value="<?= $notifications['smtp_username'] ?>" />
|
<input type="text" name="smtpusername" id="smtpusername" placeholder="<?= translate('smtp_username', $i18n) ?>" value="<?= $notifications['smtp_username'] ?>" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -743,7 +743,6 @@ label {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.form-group-inline label {
|
.form-group-inline label {
|
||||||
font-weight: 300;
|
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
margin-bottom: 0px;
|
margin-bottom: 0px;
|
||||||
margin-left: 0px;
|
margin-left: 0px;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user