mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 11:09:18 +02:00
fix(smtp-test): catch SmtpSendException to surface delivery errors as flash messages
This commit is contained in:
@@ -32,14 +32,14 @@ if (!SmtpRelay::isConfigured($db)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$subject = 'Test SMTP — XAMXAM';
|
||||
$subject = 'Test SMTP - XAMXAM';
|
||||
$sentDate = date('d/m/Y à H:i:s');
|
||||
$toSafe = htmlspecialchars($to);
|
||||
$body = <<<HTML
|
||||
<html>
|
||||
<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;">
|
||||
Test d'envoi SMTP — XAMXAM
|
||||
Test d'envoi SMTP - XAMXAM
|
||||
</h1>
|
||||
<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>
|
||||
@@ -52,12 +52,18 @@ $body = <<<HTML
|
||||
</html>
|
||||
HTML;
|
||||
|
||||
$ok = SmtpRelay::send($db, $to, $subject, $body);
|
||||
|
||||
if ($ok) {
|
||||
App::flash('success', "E-mail de test envoyé à « {$to} ».");
|
||||
} else {
|
||||
App::flash('error', "Échec de l'envoi. Vérifiez la configuration SMTP et les logs serveur.");
|
||||
try {
|
||||
$ok = SmtpRelay::send($db, $to, $subject, $body);
|
||||
if ($ok) {
|
||||
App::flash('success', "E-mail de test envoyé à « {$to} ».");
|
||||
} else {
|
||||
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');
|
||||
|
||||
@@ -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":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":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