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:
+
+
+
+ |
+
+
+
+
+ |
+
+ 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