From 9f89384166b4b7b953a3c4aa5748d8f735859113 Mon Sep 17 00:00:00 2001 From: Jonas Kohl Date: Thu, 26 Dec 2024 11:11:25 +0100 Subject: Error handling --- cgi/contact.php | 40 +++++++++++++++++++---------------- includes/desktop/components/alert.php | 1 + pages/sent-error.php | 5 +++++ 3 files changed, 28 insertions(+), 18 deletions(-) create mode 100644 pages/sent-error.php diff --git a/cgi/contact.php b/cgi/contact.php index ce265c2..2a8d579 100755 --- a/cgi/contact.php +++ b/cgi/contact.php @@ -1,5 +1,6 @@ send((new Email()) - ->from(new Address($serviceAddress, "Mystic House Corner")) - ->to($sender) - ->subject("Ihre Kontaktanfrage ist bei uns eingegangen") - ->text($body) -); - -$body = "Am $time schrieb $name via Kontaktformular:\n" . quote($message) . "\n"; - -$transport->send((new Email()) - ->from(new Address($serviceAddress, $name)) - ->to("mystic@jonaskohl.de") - ->replyTo($sender) - ->subject("[Mystic House Corner] $subject") - ->text($body) -); - -header("Location: /pages/sent.php"); +try { + $transport->send((new Email()) + ->from(new Address($serviceAddress, "Mystic House Corner")) + ->to($sender) + ->subject("Ihre Kontaktanfrage ist bei uns eingegangen") + ->text($body) + ); + + $body = "Am $time schrieb $name via Kontaktformular:\n" . quote($message) . "\n"; + + $transport->send((new Email()) + ->from(new Address($serviceAddress, $name)) + ->to("mystic@jonaskohl.de") + ->replyTo($sender) + ->subject("[Mystic House Corner] $subject") + ->text($body) + ); + header("Location: /pages/sent.php"); +} catch (TransportException $ex) { + header("Location: /pages/sent_error.php"); +} diff --git a/includes/desktop/components/alert.php b/includes/desktop/components/alert.php index a47b99b..0077f18 100644 --- a/includes/desktop/components/alert.php +++ b/includes/desktop/components/alert.php @@ -4,6 +4,7 @@ function c_alert(string $html_message, string $type, ?string $icon = null): void "warning" => ["olive","yellow"], "success" => ["green","lime"], "info" => ["teal","aqua"], + "danger" => ["maroon","pink"], ][$type] ?? ["gray","white"]; if ($icon !== null) $icon = [ diff --git a/pages/sent-error.php b/pages/sent-error.php new file mode 100644 index 0000000..67e2318 --- /dev/null +++ b/pages/sent-error.php @@ -0,0 +1,5 @@ + + +Fehler beim Verarbeiten Ihrer Nachricht! Ist die von Ihnen eingegebene eMail-Adresse korrekt?', 'danger'); ?> + + -- cgit v1.2.3