Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.
add multi email recipients
Pol0fb8fb272e29
diff --git a/endpoints/cronjobs/sendcancellationnotifications.php b/endpoints/cronjobs/sendcancellationnotifications.phpindex 0856e8b..0b11c68 100644--- a/endpoints/cronjobs/sendcancellationnotifications.php+++ b/endpoints/cronjobs/sendcancellationnotifications.php@@ -42,6 +42,7 @@ while ($userToNotify = $usersToNotify->fetchArray(SQLITE3_ASSOC)) {$email['smtpUsername'] = $row["smtp_username"];$email['smtpPassword'] = $row["smtp_password"];$email['fromEmail'] = $row["from_email"] ? $row["from_email"] : "[email protected]";+ $email['otherEmail'] = $row["other_email"];}// Check if Discord notifications are enabled and get the settings@@ -216,6 +217,13 @@ while ($userToNotify = $usersToNotify->fetchArray(SQLITE3_ASSOC)) {$mail->setFrom($email['fromEmail'], 'Wallos App');$mail->addAddress($emailaddress, $name);+ if (!empty($email['otherEmail'])) {+ $list = explode(';', $email['otherEmail']);+ foreach($list as $value) {+ $mail->addCC(trim($value));+ }+ }+$mail->Subject = 'Wallos Cancellation Notification';$mail->Body = $message;diff --git a/endpoints/cronjobs/sendnotifications.php b/endpoints/cronjobs/sendnotifications.phpindex 0c5a5b3..842207e 100644--- a/endpoints/cronjobs/sendnotifications.php+++ b/endpoints/cronjobs/sendnotifications.php@@ -60,6 +60,7 @@ while ($userToNotify = $usersToNotify->fetchArray(SQLITE3_ASSOC)) {$email['smtpUsername'] = $row["smtp_username"];$email['smtpPassword'] = $row["smtp_password"];$email['fromEmail'] = $row["from_email"] ? $row["from_email"] : "[email protected]";+ $email['otherEmail'] = $row["other_email"];}// Check if Discord notifications are enabled and get the settings@@ -260,6 +261,13 @@ while ($userToNotify = $usersToNotify->fetchArray(SQLITE3_ASSOC)) {$mail->setFrom($email['fromEmail'], 'Wallos App');$mail->addAddress($emailaddress, $name);+ if (!empty($email['otherEmail'])) {+ $list = explode(';', $email['otherEmail']);+ foreach($list as $value) {+ $mail->addCC(trim($value));+ }+ }+$mail->Subject = 'Wallos Notification';$mail->Body = $message;diff --git a/endpoints/notifications/saveemailnotifications.php b/endpoints/notifications/saveemailnotifications.phpindex 1965462..8ef13f7 100644--- a/endpoints/notifications/saveemailnotifications.php+++ b/endpoints/notifications/saveemailnotifications.php@@ -34,6 +34,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {$smtpUsername = $data["smtpusername"];$smtpPassword = $data["smtppassword"];$fromEmail = $data["fromemail"];+ $otherEmail = $data["otheremail"];$query = "SELECT COUNT(*) FROM email_notifications WHERE user_id = :userId";$stmt = $db->prepare($query);@@ -50,12 +51,12 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {$row = $result->fetchArray();$count = $row[0];if ($count == 0) {- $query = "INSERT INTO email_notifications (enabled, smtp_address, smtp_port, smtp_username, smtp_password, from_email, encryption, user_id)- VALUES (:enabled, :smtpAddress, :smtpPort, :smtpUsername, :smtpPassword, :fromEmail, :encryption, :userId)";+ $query = "INSERT INTO email_notifications (enabled, smtp_address, smtp_port, smtp_username, smtp_password, from_email, other_email, encryption, user_id)+ VALUES (:enabled, :smtpAddress, :smtpPort, :smtpUsername, :smtpPassword, :fromEmail, :otherEmail, :encryption, :userId)";} else {$query = "UPDATE email_notificationsSET enabled = :enabled, smtp_address = :smtpAddress, smtp_port = :smtpPort,- smtp_username = :smtpUsername, smtp_password = :smtpPassword, from_email = :fromEmail, encryption = :encryption WHERE user_id = :userId";+ smtp_username = :smtpUsername, smtp_password = :smtpPassword, from_email = :fromEmail, other_email = :otherEmail, encryption = :encryption WHERE user_id = :userId";}$stmt = $db->prepare($query);@@ -65,6 +66,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {$stmt->bindValue(':smtpUsername', $smtpUsername, SQLITE3_TEXT);$stmt->bindValue(':smtpPassword', $smtpPassword, SQLITE3_TEXT);$stmt->bindValue(':fromEmail', $fromEmail, SQLITE3_TEXT);+ $stmt->bindValue(':otherEmail', $otherEmail, SQLITE3_TEXT);$stmt->bindValue(':encryption', $encryption, SQLITE3_TEXT);$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);diff --git a/includes/i18n/en.php b/includes/i18n/en.phpindex a1f1b06..73d1af0 100644--- a/includes/i18n/en.php+++ b/includes/i18n/en.php@@ -140,6 +140,7 @@ $i18n = ["smtp_username" => "SMTP Username","smtp_password" => "SMTP Password","from_email" => "From email (Optional)",+ "other_email" => "Other email (Use ; to separate)","smtp_info" => "SMTP Password is transmitted and stored in plaintext. For security, please create an account just for this.","telegram" => "Telegram","telegram_bot_token" => "Telegram Bot Token",diff --git a/includes/i18n/it.php b/includes/i18n/it.phpindex 19fdfa6..4ad81ea 100644--- a/includes/i18n/it.php+++ b/includes/i18n/it.php@@ -148,6 +148,7 @@ $i18n = ['smtp_username' => 'Nome utente SMTP','smtp_password' => 'Password SMTP','from_email' => 'Da quale e-mail (Opzionale)',+ "other_email" => "Altre e-mail (Usa ; per separare)",'smtp_info' => 'La password SMTP viene memorizzata e trasmessa in chiaro. Per motivi di sicurezza, si prega di creare un account da utilizzare solo per questo.',"telegram" => "Telegram","telegram_bot_token" => "Telegram Bot Token",diff --git a/migrations/000026.php b/migrations/000026.phpnew file mode 100644index 0000000..bd773e0--- /dev/null+++ b/migrations/000026.php@@ -0,0 +1,10 @@+<?php+// This migration adds a "other_email" column to the email_notifications table.++/** @noinspection PhpUndefinedVariableInspection */+$columnQuery = $db->query("SELECT * FROM pragma_table_info('email_notifications') where name='other_email'");+$columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) === false;++if ($columnRequired) {+ $db->exec('ALTER TABLE email_notifications ADD COLUMN other_email TEXT DEFAULT "";');+}diff --git a/scripts/notifications.js b/scripts/notifications.jsindex bb67040..a83df1a 100644--- a/scripts/notifications.js+++ b/scripts/notifications.js@@ -65,6 +65,7 @@ function saveNotificationsEmailButton() {const smtpUsername = document.getElementById("smtpusername").value;const smtpPassword = document.getElementById("smtppassword").value;const fromEmail = document.getElementById("fromemail").value;+ const otherEmail = document.getElementById("otheremail").value;const data = {enabled: enabled,@@ -73,7 +74,8 @@ function saveNotificationsEmailButton() {encryption: encryption,smtpusername: smtpUsername,smtppassword: smtpPassword,- fromemail: fromEmail+ fromemail: fromEmail,+ otheremail: otherEmail};makeFetchCall('endpoints/notifications/saveemailnotifications.php', data, button);diff --git a/settings.php b/settings.phpindex 5cf7d65..857844b 100644--- a/settings.php+++ b/settings.php@@ -249,6 +249,7 @@ require_once 'includes/header.php';$notificationsEmail['smtp_username'] = $row['smtp_username'];$notificationsEmail['smtp_password'] = $row['smtp_password'];$notificationsEmail['from_email'] = $row['from_email'];+ $notificationsEmail['other_email'] = $row['other_email'];$rowCount++;}@@ -260,6 +261,7 @@ require_once 'includes/header.php';$notificationsEmail['smtp_username'] = "";$notificationsEmail['smtp_password'] = "";$notificationsEmail['from_email'] = "";+ $notificationsEmail['other_email'] = "";}// Discord notifications@@ -481,6 +483,11 @@ require_once 'includes/header.php';placeholder="<?= translate('from_email', $i18n) ?>"value="<?= $notificationsEmail['from_email'] ?>" /></div>+ <div class="form-group-inline">+ <input type="text" name="otheremail" id="otheremail"+ placeholder="<?= translate('other_email', $i18n) ?>"+ value="<?= $notificationsEmail['other_email'] ?>" />+ </div><div class="buttons"><input type="button" class="secondary-button thin mobile-grow"value="<?= translate('test', $i18n) ?>" id="testNotificationsEmail"