mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 11:09:18 +02:00
Handle SMTP 550 recipient-rejected errors with structured SmtpSendException
- Add SmtpSendException with smtpCode/smtpResponse/isRecipientRejected() - smtpSend() $expect closure throws SmtpSendException (with code) instead of RuntimeException - SmtpRelay::send() re-throws SmtpSendException so callers can inspect it - request-access.php (new): catch 550 → roll back token+approval, return HTTP 422 with FR user message - request-access.php (resend): catch 550 → HTTP 422 instead of silently claiming success - StudentEmail::sendConfirmation(): catch SmtpSendException → log+false (submission not aborted) - admin/actions/access-request.php: catch SmtpSendException post-approval → flash warning (recipient-rejected vs transient)
This commit is contained in:
@@ -52,9 +52,16 @@ try {
|
||||
$body = buildApprovalEmail($thesisTitle, $thesisAuthors, $accessUrl, $notes);
|
||||
$plain = strip_tags($body);
|
||||
|
||||
SmtpRelay::send($db, $request['email'], $subject, $body, $plain);
|
||||
|
||||
App::flash('success', "Demande approuvée. Email envoyé à {$request['email']}.");
|
||||
try {
|
||||
SmtpRelay::send($db, $request['email'], $subject, $body, $plain);
|
||||
App::flash('success', "Demande approuvée. Email envoyé à {$request['email']}.");
|
||||
} catch (SmtpSendException $e) {
|
||||
error_log('[access-request] Email delivery failed after approval: ' . $e->getMessage());
|
||||
$smtpMsg = $e->isRecipientRejected()
|
||||
? "Demande approuvée, mais l'email n'a pas pu être délivré : adresse inconnue ({$request['email']})."
|
||||
: "Demande approuvée, mais l'envoi de l'email a échoué (erreur SMTP). L'utilisateur devra relancer une demande.";
|
||||
App::flash('warning', $smtpMsg);
|
||||
}
|
||||
|
||||
} elseif ($action === 'reject') {
|
||||
$db->rejectAccessRequest($requestId, $notes);
|
||||
|
||||
Reference in New Issue
Block a user