isSMTP(); $mail->Host = $config['smtp_host']; $mail->SMTPAuth = true; $mail->Username = $config['smtp_username']; $mail->Password = $config['smtp_password']; $mail->SMTPSecure = $config['smtp_encryption']; $mail->Port = $config['smtp_port']; $mail->CharSet = 'UTF-8'; // Absender $mail->setFrom($config['from_email'], $config['from_name']); $mail->addReplyTo($email, $name); // Empfänger $mail->addAddress($config['to_email'], $config['to_name']); // Inhalt $mail->isHTML(true); $mail->Subject = 'Kontaktformular: ' . $subject; $htmlMessage = "

Neue Kontaktanfrage

Name:
" . htmlspecialchars($name) . "
E-Mail:
" . htmlspecialchars($email) . "
Thema:
" . htmlspecialchars($subject) . "
Nachricht:
" . nl2br(htmlspecialchars($message)) . "
"; $mail->Body = $htmlMessage; $mail->AltBody = "Name: $name\nE-Mail: $email\nThema: $subject\n\nNachricht:\n$message"; // E-Mail senden $mail->send(); echo 'OK'; } catch (Exception $e) { error_log('PHPMailer Error: ' . $mail->ErrorInfo); http_response_code(500); die('Fehler beim Senden der Nachricht. Bitte versuchen Sie es später erneut.'); } ?>