smtp: add notify_email field; fix admin notification sent to no-reply sender

This commit is contained in:
Pontoporeia
2026-04-30 12:19:33 +02:00
parent bdb68479d5
commit 33987c9b15
7 changed files with 81 additions and 42 deletions

View File

@@ -34,12 +34,13 @@ if ($section === 'formulaire') {
App::flash('success', "Types de travaux mis à jour.");
} elseif ($section === 'smtp') {
$smtpData = [
'host' => $_POST['smtp_host'] ?? '',
'port' => $_POST['smtp_port'] ?? 587,
'encryption' => $_POST['smtp_encryption'] ?? 'tls',
'username' => $_POST['smtp_username'] ?? '',
'from_email' => $_POST['smtp_from_email'] ?? '',
'from_name' => $_POST['smtp_from_name'] ?? 'XAMXAM',
'host' => $_POST['smtp_host'] ?? '',
'port' => $_POST['smtp_port'] ?? 587,
'encryption' => $_POST['smtp_encryption'] ?? 'tls',
'username' => $_POST['smtp_username'] ?? '',
'from_email' => $_POST['smtp_from_email'] ?? '',
'from_name' => $_POST['smtp_from_name'] ?? 'XAMXAM',
'notify_email' => $_POST['smtp_notify_email'] ?? '',
];
// Only update password when user actually typed something.
$pwd = $_POST['smtp_password'] ?? '';

View File

@@ -188,9 +188,9 @@ try {
);
$plain = htmlToPlain($body);
$settings = SmtpRelay::getSettings($db);
if (!empty($settings['from_email'])) {
SmtpRelay::send($db, $settings['from_email'], $subject, $body, $plain);
$notifyEmail = SmtpRelay::getNotifyEmail($db);
if ($notifyEmail !== '') {
SmtpRelay::send($db, $notifyEmail, $subject, $body, $plain);
}
http_response_code(200);