Forráskód Böngészése

adding logging for all sent mail

Medowar 2 hete
szülő
commit
28f91d36c7
1 módosított fájl, 15 hozzáadás és 0 törlés
  1. 15 0
      src/mail/mailer.php

+ 15 - 0
src/mail/mailer.php

@@ -33,6 +33,7 @@ final class Mailer
     {
         $email = strtolower(trim($email));
         if ($email === '') {
+            Bootstrap::log('mail', 'Versand OTP übersprungen: leere E-Mail-Adresse');
             return false;
         }
 
@@ -51,6 +52,8 @@ final class Mailer
                 Bootstrap::log('mail', 'Versand OTP fehlgeschlagen: ' . $email . ' - ' . $mail->getErrorInfo());
                 return false;
             }
+
+            Bootstrap::log('mail', 'Versand OTP erfolgreich: ' . $email);
         } catch (\Throwable $e) {
             Bootstrap::log('mail', 'Versand OTP fehlgeschlagen: ' . $email . ' - ' . $e->getMessage());
             return false;
@@ -62,6 +65,8 @@ final class Mailer
     /** @param array<string, mixed> $submission */
     public function sendSubmissionMails(array $submission): void
     {
+        Bootstrap::log('mail', 'Versandprozess Antrag gestartet für: ' . (string) ($submission['email'] ?? 'unbekannt'));
+
         $formDataPdf = $this->pdfGenerator->generateFormDataPdf($submission);
         $minorSignaturePdf = $this->pdfGenerator->generateMinorSignaturePdf($submission);
         $isMinorSubmission = $this->isMinorSubmission($submission);
@@ -76,6 +81,8 @@ final class Mailer
             if ($minorSignaturePdf !== null) {
                 @unlink($minorSignaturePdf);
             }
+
+            Bootstrap::log('mail', 'Versandprozess Antrag abgeschlossen für: ' . (string) ($submission['email'] ?? 'unbekannt'));
         }
     }
 
@@ -141,7 +148,11 @@ final class Mailer
 
                 if (!$mail->send()) {
                     Bootstrap::log('mail', 'Versand an Admin fehlgeschlagen: ' . $recipient . ' - ' . $mail->getErrorInfo());
+                    continue;
                 }
+
+                $ccInfo = $ccEmails !== [] ? (' | CC: ' . implode(', ', $ccEmails)) : '';
+                Bootstrap::log('mail', 'Versand an Admin erfolgreich: ' . $recipient . $ccInfo);
             } catch (\Throwable $e) {
                 Bootstrap::log('mail', 'Versand an Admin fehlgeschlagen: ' . $recipient . ' - ' . $e->getMessage());
             }
@@ -153,6 +164,7 @@ final class Mailer
     {
         $email = (string) ($submission['email'] ?? '');
         if ($email === '') {
+            Bootstrap::log('mail', 'Versand an Antragsteller übersprungen: leere E-Mail-Adresse');
             return;
         }
 
@@ -174,7 +186,10 @@ final class Mailer
 
             if (!$mail->send()) {
                 Bootstrap::log('mail', 'Versand an Antragsteller fehlgeschlagen: ' . $email . ' - ' . $mail->getErrorInfo());
+                return;
             }
+
+            Bootstrap::log('mail', 'Versand an Antragsteller erfolgreich: ' . $email);
         } catch (\Throwable $e) {
             Bootstrap::log('mail', 'Versand an Antragsteller fehlgeschlagen: ' . $email . ' - ' . $e->getMessage());
         }