From 7e8d862aea2aa5f25e91cf9018922bc4163e2e4b Mon Sep 17 00:00:00 2001 From: webfarben Date: Tue, 3 Feb 2026 10:35:53 +0100 Subject: [PATCH] =?UTF-8?q?Feature:=20Professionelles=20HTML-Mail-Template?= =?UTF-8?q?=20f=C3=BCr=20Kontaktformular?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Modernes responsives Design mit Gradient-Header - Tabellarische Darstellung der Formulardaten - Inline CSS für maximale E-Mail-Client-Kompatibilität - Plain-Text Fallback (AltBody) beibehalten - Zeilenumbrüche werden korrekt in HTML konvertiert - XSS-Schutz und Sicherheit beibehalten - HKW Branding im Footer --- .../vendor/php-email-form/php-email-form.php | 91 ++++++++++++++++++- 1 file changed, 86 insertions(+), 5 deletions(-) diff --git a/assets/vendor/php-email-form/php-email-form.php b/assets/vendor/php-email-form/php-email-form.php index d71edb4..a705c8e 100644 --- a/assets/vendor/php-email-form/php-email-form.php +++ b/assets/vendor/php-email-form/php-email-form.php @@ -57,14 +57,33 @@ class PHP_Email_Form { public function add_message(string $content, string $label = '', ?int $length_check = null): void { $content = strip_tags($content); - $message = htmlspecialchars($content, ENT_QUOTES, 'UTF-8') . '
'; if ($length_check !== null && strlen($content) < $length_check) { $this->error .= $label . ' ' . $this->error_messages['short'] . '
'; return; } - $this->message .= !empty($label) ? "$label: $message" : $message; + $escaped_content = htmlspecialchars($content, ENT_QUOTES, 'UTF-8'); + $escaped_content = nl2br($escaped_content); // Zeilenumbrüche in
konvertieren + + if (!empty($label)) { + $this->message .= " + + + $label: + + + $escaped_content + + "; + } else { + $this->message .= " + + + $escaped_content + + "; + } } public function add_attachment($field_name, $max_size = 20, $allowed_types = ['pdf', 'doc', 'docx', 'jpg', 'jpeg', 'png', 'gif']): void { @@ -127,11 +146,14 @@ class PHP_Email_Form { ); } + // HTML Template für professionelle E-Mail + $html_body = $this->buildHtmlTemplate(); + // Content $mail->isHTML(true); $mail->Subject = $this->subject; - $mail->Body = $this->message; - $mail->AltBody = strip_tags(str_replace('
', "\n", $this->message)); + $mail->Body = $html_body; + $mail->AltBody = strip_tags(str_replace(['
', ''], ["\n", "\n"], $this->message)); $mail->send(); return 'OK'; @@ -140,4 +162,63 @@ class PHP_Email_Form { return 'Mailer Error: ' . $mail->ErrorInfo; } } -} \ No newline at end of file + + private function buildHtmlTemplate(): string { + $current_year = date('Y'); + return << + + + + + {$this->subject} + + + + + + +
+ + + + + + + + + + + + + + + +
+

+ Neue Kontaktanfrage +

+

+ HKW Anwälte Webformular +

+
+

+ Sie haben eine neue Nachricht über das Kontaktformular erhalten: +

+ + + {$this->message} +
+
+

+ Diese E-Mail wurde automatisch generiert.
+ Bitte antworten Sie nicht auf diese E-Mail.
+ HKW Anwälte © {$current_year} +

+
+
+ + +HTML; + } +} \ No newline at end of file