mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
fix(smtp-test): catch SmtpSendException to surface delivery errors as flash messages
This commit is contained in:
3
TODO.md
3
TODO.md
@@ -17,6 +17,9 @@
|
|||||||
- [x] **add.php / edit.php / partage/index.php** — use `sortable.min.js` + `file-upload-queue.js` instead of `file-preview.js`
|
- [x] **add.php / edit.php / partage/index.php** — use `sortable.min.js` + `file-upload-queue.js` instead of `file-preview.js`
|
||||||
- [x] **docs/file-uploads.md** — reference document covering accepted types, size limits, storage layout, ordering, labels, security, and source file index
|
- [x] **docs/file-uploads.md** — reference document covering accepted types, size limits, storage layout, ordering, labels, security, and source file index
|
||||||
|
|
||||||
|
## Bug fixes
|
||||||
|
- [x] **smtp-test.php** — wrap `SmtpRelay::send()` in `try/catch SmtpSendException` so SMTP delivery failures (e.g. 550 recipient rejected) surface as a proper flash error instead of an uncaught exception/silent crash
|
||||||
|
|
||||||
## Previously completed
|
## Previously completed
|
||||||
- [x] Multi-file upload for thesis files (basic)
|
- [x] Multi-file upload for thesis files (basic)
|
||||||
- [x] File access restriction system (email approval workflow)
|
- [x] File access restriction system (email approval workflow)
|
||||||
|
|||||||
@@ -32,14 +32,14 @@ if (!SmtpRelay::isConfigured($db)) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$subject = 'Test SMTP — XAMXAM';
|
$subject = 'Test SMTP - XAMXAM';
|
||||||
$sentDate = date('d/m/Y à H:i:s');
|
$sentDate = date('d/m/Y à H:i:s');
|
||||||
$toSafe = htmlspecialchars($to);
|
$toSafe = htmlspecialchars($to);
|
||||||
$body = <<<HTML
|
$body = <<<HTML
|
||||||
<html>
|
<html>
|
||||||
<body style="font-family: sans-serif; color: #222; max-width: 600px; margin: 0 auto; padding: 24px;">
|
<body style="font-family: sans-serif; color: #222; max-width: 600px; margin: 0 auto; padding: 24px;">
|
||||||
<h1 style="font-size: 1.4rem; border-bottom: 2px solid #c00; padding-bottom: 8px;">
|
<h1 style="font-size: 1.4rem; border-bottom: 2px solid #c00; padding-bottom: 8px;">
|
||||||
Test d'envoi SMTP — XAMXAM
|
Test d'envoi SMTP - XAMXAM
|
||||||
</h1>
|
</h1>
|
||||||
<p>Ceci est un e-mail de test envoyé depuis l'interface d'administration de <strong>XAMXAM</strong>.</p>
|
<p>Ceci est un e-mail de test envoyé depuis l'interface d'administration de <strong>XAMXAM</strong>.</p>
|
||||||
<p>Si vous recevez ce message, la configuration du relay SMTP est correcte.</p>
|
<p>Si vous recevez ce message, la configuration du relay SMTP est correcte.</p>
|
||||||
@@ -52,13 +52,19 @@ $body = <<<HTML
|
|||||||
</html>
|
</html>
|
||||||
HTML;
|
HTML;
|
||||||
|
|
||||||
|
try {
|
||||||
$ok = SmtpRelay::send($db, $to, $subject, $body);
|
$ok = SmtpRelay::send($db, $to, $subject, $body);
|
||||||
|
|
||||||
if ($ok) {
|
if ($ok) {
|
||||||
App::flash('success', "E-mail de test envoyé à « {$to} ».");
|
App::flash('success', "E-mail de test envoyé à « {$to} ».");
|
||||||
} else {
|
} else {
|
||||||
App::flash('error', "Échec de l'envoi. Vérifiez la configuration SMTP et les logs serveur.");
|
App::flash('error', "Échec de l'envoi. Vérifiez la configuration SMTP et les logs serveur.");
|
||||||
}
|
}
|
||||||
|
} catch (SmtpSendException $e) {
|
||||||
|
$detail = $e->isRecipientRejected()
|
||||||
|
? "Adresse rejetée par le serveur ({$to}) : " . $e->smtpResponse
|
||||||
|
: "Erreur SMTP : " . $e->smtpResponse;
|
||||||
|
App::flash('error', $detail);
|
||||||
|
}
|
||||||
|
|
||||||
header('Location: /admin/parametres.php');
|
header('Location: /admin/parametres.php');
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
@@ -2,3 +2,5 @@
|
|||||||
{"source":"partage","action":"submit","status":"success","thesis_id":16,"identifier":"2025-013","author":"Emma Renard","share_slug":"20260429-DZESJT6X","timestamp":"2026-04-30T09:35:49+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0"}
|
{"source":"partage","action":"submit","status":"success","thesis_id":16,"identifier":"2025-013","author":"Emma Renard","share_slug":"20260429-DZESJT6X","timestamp":"2026-04-30T09:35:49+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0"}
|
||||||
{"source":"partage","action":"submit","status":"success","thesis_id":17,"identifier":"2025-014","author":"Théo Marchand","share_slug":"20260429-DZESJT6X","timestamp":"2026-04-30T09:48:20+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0"}
|
{"source":"partage","action":"submit","status":"success","thesis_id":17,"identifier":"2025-014","author":"Théo Marchand","share_slug":"20260429-DZESJT6X","timestamp":"2026-04-30T09:48:20+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0"}
|
||||||
{"source":"partage","action":"submit","status":"success","thesis_id":18,"identifier":"2025-015","author":"Théo Marchand","share_slug":"20260429-DZESJT6X","timestamp":"2026-04-30T10:13:43+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0"}
|
{"source":"partage","action":"submit","status":"success","thesis_id":18,"identifier":"2025-015","author":"Théo Marchand","share_slug":"20260429-DZESJT6X","timestamp":"2026-04-30T10:13:43+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0"}
|
||||||
|
{"source":"partage","action":"submit","status":"success","thesis_id":19,"identifier":"2025-016","author":"Lila Dubois, Karim Nassar","share_slug":"20260429-DZESJT6X","timestamp":"2026-04-30T11:27:07+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0"}
|
||||||
|
{"source":"partage","action":"submit","status":"success","thesis_id":20,"identifier":"2025-017","author":"Théo Marchand","share_slug":"20260429-DZESJT6X","timestamp":"2026-04-30T11:37:11+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0"}
|
||||||
|
|||||||
Reference in New Issue
Block a user