From 0e49848a7896797476371c7d0d4a887c0b59a1b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20M=C3=BCller?= Date: Thu, 31 Jul 2025 15:47:00 +0200 Subject: [PATCH] =?UTF-8?q?Formular-Handling=20verbessert:=20CSRF-Token=20?= =?UTF-8?q?hinzugef=C3=BCgt,=20AJAX-Formular=C3=BCbermittlung=20implementi?= =?UTF-8?q?ert=20und=20neue=20CSS-Stile=20f=C3=BCr=20verschiedene=20Abschn?= =?UTF-8?q?itte=20hinzugef=C3=BCgt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/.htaccess | 96 ++++++++++ public/README-EMAIL-SETUP.md | 199 ++++++++++++++++++++ public/assets/css/style.css | 114 ++++++++++++ public/assets/js/contact.js | 39 ++-- public/composer.json | 19 ++ public/config/mail-config.php | 155 ++++++++++++++++ public/contact-handler.php | 330 ++++++++++++++++++++++++++++++++++ public/contact.html | 7 +- 8 files changed, 944 insertions(+), 15 deletions(-) create mode 100644 public/.htaccess create mode 100644 public/README-EMAIL-SETUP.md create mode 100644 public/composer.json create mode 100644 public/config/mail-config.php create mode 100644 public/contact-handler.php diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..a4bc824 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,96 @@ +# HexaHost.de .htaccess +# Sicherheit und Performance-Optimierungen + +# Sicherheitsheader + + Header always set X-Content-Type-Options nosniff + Header always set X-Frame-Options DENY + Header always set X-XSS-Protection "1; mode=block" + Header always set Referrer-Policy "strict-origin-when-cross-origin" + Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()" + + +# HTTPS erzwingen (falls SSL verfügbar) + + RewriteEngine On + RewriteCond %{HTTPS} off + RewriteCond %{HTTP_HOST} ^(www\.)?hexahost\.de$ [NC] + RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] + + +# Konfigurationsdateien schützen + + Order allow,deny + Deny from all + + + + Order allow,deny + Deny from all + + + + Order allow,deny + Deny from all + + +# Logs-Verzeichnis schützen + + Order allow,deny + Deny from all + + +# Vendor-Verzeichnis schützen + + Order allow,deny + Deny from all + + +# Cache-Header für statische Dateien + + ExpiresActive On + ExpiresByType text/css "access plus 1 month" + ExpiresByType application/javascript "access plus 1 month" + ExpiresByType image/png "access plus 1 month" + ExpiresByType image/jpg "access plus 1 month" + ExpiresByType image/jpeg "access plus 1 month" + ExpiresByType image/gif "access plus 1 month" + ExpiresByType image/svg+xml "access plus 1 month" + ExpiresByType image/webp "access plus 1 month" + ExpiresByType font/woff "access plus 1 month" + ExpiresByType font/woff2 "access plus 1 month" + + +# Gzip-Kompression + + AddOutputFilterByType DEFLATE text/plain + AddOutputFilterByType DEFLATE text/html + AddOutputFilterByType DEFLATE text/xml + AddOutputFilterByType DEFLATE text/css + AddOutputFilterByType DEFLATE application/xml + AddOutputFilterByType DEFLATE application/xhtml+xml + AddOutputFilterByType DEFLATE application/rss+xml + AddOutputFilterByType DEFLATE application/javascript + AddOutputFilterByType DEFLATE application/x-javascript + + +# PHP-Einstellungen + + php_value upload_max_filesize 10M + php_value post_max_size 10M + php_value max_execution_time 30 + php_value memory_limit 128M + + +# Fehlerbehandlung +ErrorDocument 404 /404.html +ErrorDocument 500 /500.html + +# Verzeichnis-Listing deaktivieren +Options -Indexes + +# Datei-Zugriff beschränken + + Order Allow,Deny + Deny from all + \ No newline at end of file diff --git a/public/README-EMAIL-SETUP.md b/public/README-EMAIL-SETUP.md new file mode 100644 index 0000000..d5ec059 --- /dev/null +++ b/public/README-EMAIL-SETUP.md @@ -0,0 +1,199 @@ +# HexaHost.de E-Mail-Setup Anleitung + +## Übersicht + +Das Kontaktformular ist jetzt vollständig funktional mit einem PHP-Backend und PHPMailer. Sie müssen nur noch Ihre SMTP-Daten konfigurieren. + +## Installation + +### 1. Composer installieren + +```bash +cd public +composer install +``` + +### 2. SMTP-Konfiguration + +Bearbeiten Sie die Datei `config/mail-config.php` und passen Sie die SMTP-Einstellungen an: + +```php +// SMTP Server Einstellungen +define('SMTP_HOST', 'smtp.ihre-domain.de'); // Ihr SMTP-Server +define('SMTP_PORT', 587); // SMTP-Port (meist 587 oder 465) +define('SMTP_USERNAME', 'kontakt@ihre-domain.de'); // Ihr SMTP-Benutzername +define('SMTP_PASSWORD', 'ihr-smtp-passwort'); // Ihr SMTP-Passwort + +// E-Mail Adressen +define('SMTP_FROM_EMAIL', 'kontakt@hexahost.de'); // Absender-E-Mail +define('SMTP_TO_EMAIL', 'info@hexahost.de'); // Empfänger-E-Mail +``` + +## Gängige SMTP-Einstellungen + +### Gmail +```php +define('SMTP_HOST', 'smtp.gmail.com'); +define('SMTP_PORT', 587); +define('SMTP_USERNAME', 'ihre-email@gmail.com'); +define('SMTP_PASSWORD', 'ihr-app-passwort'); // App-Passwort erforderlich +``` + +### Outlook/Hotmail +```php +define('SMTP_HOST', 'smtp-mail.outlook.com'); +define('SMTP_PORT', 587); +define('SMTP_USERNAME', 'ihre-email@outlook.com'); +define('SMTP_PASSWORD', 'ihr-passwort'); +``` + +### GMX +```php +define('SMTP_HOST', 'mail.gmx.net'); +define('SMTP_PORT', 587); +define('SMTP_USERNAME', 'ihre-email@gmx.de'); +define('SMTP_PASSWORD', 'ihr-passwort'); +``` + +### Web.de +```php +define('SMTP_HOST', 'smtp.web.de'); +define('SMTP_PORT', 587); +define('SMTP_USERNAME', 'ihre-email@web.de'); +define('SMTP_PASSWORD', 'ihr-passwort'); +``` + +### 1&1 +```php +define('SMTP_HOST', 'smtp.1und1.de'); +define('SMTP_PORT', 587); +define('SMTP_USERNAME', 'ihre-email@ihre-domain.de'); +define('SMTP_PASSWORD', 'ihr-passwort'); +``` + +### Strato +```php +define('SMTP_HOST', 'smtp.strato.de'); +define('SMTP_PORT', 587); +define('SMTP_USERNAME', 'ihre-email@ihre-domain.de'); +define('SMTP_PASSWORD', 'ihr-passwort'); +``` + +### Ionos +```php +define('SMTP_HOST', 'smtp.ionos.de'); +define('SMTP_PORT', 587); +define('SMTP_USERNAME', 'ihre-email@ihre-domain.de'); +define('SMTP_PASSWORD', 'ihr-passwort'); +``` + +## Sicherheitsfeatures + +### Anti-Spam Headers +Das System sendet E-Mails mit folgenden Anti-Spam-Headers: +- `X-Mailer`: Identifiziert das System +- `X-Priority`: Normale Priorität +- `X-Report-Abuse`: Abuse-Reporting +- `List-Unsubscribe`: Unsubscribe-Link +- `Precedence`: Bulk-Mail-Kennzeichnung + +### Spam-Schutz +- Rate-Limiting: Max. 3 Anfragen pro 5 Minuten +- Spam-Score-System: Erkennt verdächtige Nachrichten +- Input-Validierung: Prüft alle Eingaben +- CSRF-Schutz: Verhindert Cross-Site-Request-Forgery + +### Validierung +- E-Mail-Format-Prüfung +- Pflichtfeld-Validierung +- Nachrichtenlänge (10-5000 Zeichen) +- Verdächtige Wörter-Erkennung + +## E-Mail-Templates + +### An HexaHost (HTML) +- Professionelles HTML-Template +- Alle Formulardaten übersichtlich dargestellt +- HexaHost Branding + +### Bestätigung an Kunde (HTML) +- Danke-Nachricht +- Bestätigung der Nachricht +- Support-Informationen + +## Logging + +E-Mails werden in `logs/email.log` protokolliert (falls aktiviert): +```php +define('LOG_EMAILS', true); +``` + +## Troubleshooting + +### Häufige Probleme + +1. **"SMTP connect() failed"** + - Prüfen Sie SMTP_HOST und SMTP_PORT + - Stellen Sie sicher, dass SMTP aktiviert ist + +2. **"Authentication failed"** + - Prüfen Sie SMTP_USERNAME und SMTP_PASSWORD + - Bei Gmail: App-Passwort verwenden + +3. **"Connection refused"** + - Firewall-Einstellungen prüfen + - Port 587 oder 465 verwenden + +4. **E-Mails landen im Spam** + - SPF, DKIM und DMARC konfigurieren + - Absender-Domain mit SMTP-Domain übereinstimmend + +### Debug-Modus + +Aktivieren Sie den Debug-Modus für detaillierte Fehlermeldungen: +```php +define('DEBUG_MODE', true); +``` + +## Dateistruktur + +``` +public/ +├── contact-handler.php # E-Mail-Verarbeitung +├── config/ +│ └── mail-config.php # SMTP-Konfiguration +├── vendor/ # Composer-Abhängigkeiten +├── logs/ # E-Mail-Logs +└── composer.json # Composer-Konfiguration +``` + +## Sicherheitshinweise + +1. **SMTP-Passwort schützen** + - Datei `config/mail-config.php` nicht öffentlich zugänglich machen + - Passwort regelmäßig ändern + +2. **HTTPS verwenden** + - Kontaktformular nur über HTTPS bereitstellen + - SSL-Zertifikat installieren + +3. **Backup erstellen** + - Regelmäßige Backups der Konfiguration + - E-Mail-Logs sichern + +## Support + +Bei Problemen: +1. Debug-Modus aktivieren +2. E-Mail-Logs prüfen +3. SMTP-Einstellungen testen +4. Firewall-Einstellungen überprüfen + +## Changelog + +- **v1.0**: Vollständige E-Mail-Implementierung +- Anti-Spam-Headers +- Rate-Limiting +- CSRF-Schutz +- HTML-Templates +- Logging-System \ No newline at end of file diff --git a/public/assets/css/style.css b/public/assets/css/style.css index 9074cb7..d4bc214 100644 --- a/public/assets/css/style.css +++ b/public/assets/css/style.css @@ -509,6 +509,97 @@ body { font-size: var(--font-size-sm); } +/* How it Works Section */ +.how-it-works { + padding: var(--spacing-3xl) 0; + background: rgba(255, 255, 255, 0.02); +} + +.steps-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); + gap: var(--spacing-xl); + margin-top: var(--spacing-2xl); +} + +.step-item { + padding: var(--spacing-xl); + text-align: center; + position: relative; +} + +.step-number { + width: 60px; + height: 60px; + background: linear-gradient(135deg, var(--primary-color), var(--accent-color-1)); + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + font-size: var(--font-size-xl); + font-weight: 700; + color: var(--white); + margin: 0 auto var(--spacing-lg); + box-shadow: 0 8px 32px 0 rgba(255, 81, 249, 0.3); +} + +.step-item h3 { + font-size: var(--font-size-lg); + font-weight: 600; + margin-bottom: var(--spacing-md); + color: var(--text-primary); +} + +.step-item p { + color: var(--text-secondary); + line-height: 1.6; + font-size: var(--font-size-base); +} + +/* Mail Features Section */ +.mail-features { + padding: var(--spacing-3xl) 0; + background: rgba(255, 255, 255, 0.03); +} + +/* Benefits Section */ +.benefits { + padding: var(--spacing-3xl) 0; + background: rgba(255, 255, 255, 0.02); +} + +.benefits-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); + gap: var(--spacing-xl); + margin-top: var(--spacing-2xl); +} + +.benefit-item { + padding: var(--spacing-xl); + text-align: center; +} + +.benefit-icon { + width: 48px; + height: 48px; + margin: 0 auto var(--spacing-lg); + color: var(--primary-color); +} + +.benefit-item h3 { + font-size: var(--font-size-lg); + font-weight: 600; + margin-bottom: var(--spacing-md); + color: var(--text-primary); +} + +.benefit-item p { + color: var(--text-secondary); + line-height: 1.6; + font-size: var(--font-size-base); +} + /* CTA Section */ .cta { padding: var(--spacing-3xl) 0; @@ -1263,6 +1354,19 @@ body { transition: all var(--transition-base); } +/* Spezielle Styling für Select-Elemente */ +.form-group select { + background: rgba(255, 255, 255, 0.1); + backdrop-filter: blur(10px); + -webkit-backdrop-filter: blur(10px); +} + +.form-group select option { + background: rgba(13, 8, 33, 0.95); + color: var(--text-primary); + padding: var(--spacing-sm); +} + .form-group input:focus, .form-group select:focus, .form-group textarea:focus { @@ -1444,6 +1548,16 @@ body { grid-template-columns: 1fr; } + .steps-grid { + grid-template-columns: 1fr; + gap: var(--spacing-lg); + } + + .benefits-grid { + grid-template-columns: 1fr; + gap: var(--spacing-lg); + } + .story-content { grid-template-columns: 1fr; } diff --git a/public/assets/js/contact.js b/public/assets/js/contact.js index addf78b..59d6d39 100644 --- a/public/assets/js/contact.js +++ b/public/assets/js/contact.js @@ -66,21 +66,36 @@ submitBtn.textContent = 'Wird gesendet...'; submitBtn.disabled = true; - // Simulate form submission (replace with actual endpoint) - setTimeout(() => { - // Reset form - form.reset(); - - // Show success message - showNotification('Ihre Nachricht wurde erfolgreich gesendet! Wir melden uns in Kürze bei Ihnen.', 'success'); - + // Send form data to PHP backend + fetch('contact-handler.php', { + method: 'POST', + body: formData + }) + .then(response => response.json()) + .then(data => { + if (data.success) { + // Reset form + form.reset(); + + // Show success message + showNotification(data.message, 'success'); + + // Scroll to top + window.scrollTo({ top: 0, behavior: 'smooth' }); + } else { + // Show error message + showNotification(data.message, 'error'); + } + }) + .catch(error => { + console.error('Error:', error); + showNotification('Es gab ein Problem beim Senden Ihrer Nachricht. Bitte versuchen Sie es später erneut.', 'error'); + }) + .finally(() => { // Reset button submitBtn.textContent = originalText; submitBtn.disabled = false; - - // Scroll to top - window.scrollTo({ top: 0, behavior: 'smooth' }); - }, 2000); + }); }); } diff --git a/public/composer.json b/public/composer.json new file mode 100644 index 0000000..e5a0ee9 --- /dev/null +++ b/public/composer.json @@ -0,0 +1,19 @@ +{ + "name": "hexahost/contact-form", + "description": "HexaHost.de Contact Form with PHPMailer", + "type": "project", + "require": { + "phpmailer/phpmailer": "^6.8" + }, + "autoload": { + "psr-4": { + "HexaHost\\": "src/" + } + }, + "config": { + "optimize-autoloader": true, + "sort-packages": true + }, + "minimum-stability": "stable", + "prefer-stable": true +} \ No newline at end of file diff --git a/public/config/mail-config.php b/public/config/mail-config.php new file mode 100644 index 0000000..6e10b72 --- /dev/null +++ b/public/config/mail-config.php @@ -0,0 +1,155 @@ + 'HexaHost.de Contact Form', + 'X-Priority' => '3', + 'X-MSMail-Priority' => 'Normal', + 'Importance' => 'Normal', + 'X-Report-Abuse' => 'Please report abuse here: abuse@hexahost.de', + 'List-Unsubscribe' => '', + 'Precedence' => 'bulk' +]); + +// Erlaubte Domains für E-Mail-Adressen (optional) +define('ALLOWED_EMAIL_DOMAINS', [ + // Leer lassen für alle Domains zu erlauben + // 'gmail.com', + // 'outlook.com', + // 'web.de', + // 'gmx.de' +]); + +// Blacklist für E-Mail-Adressen (optional) +define('BLACKLISTED_EMAILS', [ + // 'spam@example.com', + // 'test@test.com' +]); + +// Validierung der Konfiguration +if (!defined('SMTP_HOST') || !defined('SMTP_USERNAME') || !defined('SMTP_PASSWORD')) { + die('SMTP-Konfiguration ist unvollständig. Bitte überprüfen Sie die mail-config.php'); +} + +// Überprüfung der E-Mail-Adressen +if (!filter_var(SMTP_FROM_EMAIL, FILTER_VALIDATE_EMAIL)) { + die('Ungültige SMTP_FROM_EMAIL Adresse'); +} + +if (!filter_var(SMTP_TO_EMAIL, FILTER_VALIDATE_EMAIL)) { + die('Ungültige SMTP_TO_EMAIL Adresse'); +} + +// Logging-Funktion +function logEmail($type, $data) { + if (!LOG_EMAILS) return; + + $logFile = __DIR__ . '/../logs/email.log'; + $logDir = dirname($logFile); + + if (!is_dir($logDir)) { + mkdir($logDir, 0755, true); + } + + $timestamp = date('Y-m-d H:i:s'); + $logEntry = "[$timestamp] $type: " . json_encode($data) . "\n"; + + file_put_contents($logFile, $logEntry, FILE_APPEND | LOCK_EX); +} + +// Hilfsfunktion für E-Mail-Validierung +function isValidEmail($email) { + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { + return false; + } + + // Prüfe Blacklist + if (in_array($email, BLACKLISTED_EMAILS)) { + return false; + } + + // Prüfe Domain-Whitelist (falls gesetzt) + if (!empty(ALLOWED_EMAIL_DOMAINS)) { + $domain = substr(strrchr($email, "@"), 1); + if (!in_array($domain, ALLOWED_EMAIL_DOMAINS)) { + return false; + } + } + + return true; +} + +// CSRF Token generieren +function generateCSRFToken() { + if (!isset($_SESSION['csrf_token'])) { + $_SESSION['csrf_token'] = bin2hex(random_bytes(32)); + } + return $_SESSION['csrf_token']; +} + +// CSRF Token validieren +function validateCSRFToken($token) { + return isset($_SESSION['csrf_token']) && hash_equals($_SESSION['csrf_token'], $token); +} +?> \ No newline at end of file diff --git a/public/contact-handler.php b/public/contact-handler.php new file mode 100644 index 0000000..3f1d0c3 --- /dev/null +++ b/public/contact-handler.php @@ -0,0 +1,330 @@ + false, 'message' => 'Security token invalid']); + exit; +} + +// Rate limiting +session_start(); +$timeWindow = 300; // 5 minutes +$maxRequests = 3; + +if (!isset($_SESSION['contact_attempts'])) { + $_SESSION['contact_attempts'] = []; +} + +// Clean old attempts +$_SESSION['contact_attempts'] = array_filter($_SESSION['contact_attempts'], function($timestamp) use ($timeWindow) { + return $timestamp > (time() - $timeWindow); +}); + +if (count($_SESSION['contact_attempts']) >= $maxRequests) { + http_response_code(429); + echo json_encode(['success' => false, 'message' => 'Zu viele Anfragen. Bitte warten Sie 5 Minuten.']); + exit; +} + +// Add current attempt +$_SESSION['contact_attempts'][] = time(); + +// Validate required fields +$requiredFields = ['firstName', 'lastName', 'email', 'subject', 'message', 'privacy']; +$errors = []; + +foreach ($requiredFields as $field) { + if (!isset($_POST[$field]) || trim($_POST[$field]) === '') { + $errors[] = "Das Feld '$field' ist erforderlich."; + } +} + +// Validate email +if (isset($_POST['email']) && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { + $errors[] = 'Bitte geben Sie eine gültige E-Mail-Adresse ein.'; +} + +// Validate privacy checkbox +if (!isset($_POST['privacy']) || $_POST['privacy'] !== 'on') { + $errors[] = 'Sie müssen der Datenschutzerklärung zustimmen.'; +} + +// Check for spam indicators +$spamScore = 0; +$message = isset($_POST['message']) ? $_POST['message'] : ''; + +// Check message length +if (strlen($message) < 10) { + $spamScore += 2; +} + +if (strlen($message) > 5000) { + $spamScore += 3; +} + +// Check for suspicious patterns +$suspiciousPatterns = [ + '/\b(viagra|casino|loan|credit|debt)\b/i', + '/\b(click here|buy now|free money)\b/i', + '/\b(www\.|http:\/\/|https:\/\/)/i', + '/\b[A-Z]{5,}/', // ALL CAPS + '/\b\d{10,}/', // Too many numbers +]; + +foreach ($suspiciousPatterns as $pattern) { + if (preg_match($pattern, $message)) { + $spamScore += 1; + } +} + +// Check for too many links +$linkCount = preg_match_all('/https?:\/\/[^\s]+/', $message); +if ($linkCount > 2) { + $spamScore += 2; +} + +// Reject if spam score is too high +if ($spamScore >= 5) { + http_response_code(400); + echo json_encode(['success' => false, 'message' => 'Ihre Nachricht wurde als Spam erkannt.']); + exit; +} + +if (!empty($errors)) { + http_response_code(400); + echo json_encode(['success' => false, 'message' => implode(' ', $errors)]); + exit; +} + +// Sanitize input +$firstName = htmlspecialchars(trim($_POST['firstName']), ENT_QUOTES, 'UTF-8'); +$lastName = htmlspecialchars(trim($_POST['lastName']), ENT_QUOTES, 'UTF-8'); +$email = filter_var(trim($_POST['email']), FILTER_SANITIZE_EMAIL); +$phone = isset($_POST['phone']) ? htmlspecialchars(trim($_POST['phone']), ENT_QUOTES, 'UTF-8') : ''; +$company = isset($_POST['company']) ? htmlspecialchars(trim($_POST['company']), ENT_QUOTES, 'UTF-8') : ''; +$subject = htmlspecialchars(trim($_POST['subject']), ENT_QUOTES, 'UTF-8'); +$message = htmlspecialchars(trim($_POST['message']), ENT_QUOTES, 'UTF-8'); +$newsletter = isset($_POST['newsletter']) && $_POST['newsletter'] === 'on'; + +// Map subject to readable text +$subjectMap = [ + 'allgemeine-anfrage' => 'Allgemeine Anfrage', + 'vpc-anfrage' => 'Virtual Private Container Anfrage', + 'vps-anfrage' => 'Virtual Private Server Anfrage', + 'mail-gateway-anfrage' => 'Mail Gateway Anfrage', + 'webhosting-anfrage' => 'Webhosting Anfrage', + 'support' => 'Technischer Support', + 'beratung' => 'Persönliche Beratung', + 'migration' => 'Migration/Umzug', + 'sonstiges' => 'Sonstiges' +]; + +$subjectText = isset($subjectMap[$subject]) ? $subjectMap[$subject] : $subject; + +// Prepare email content +$emailSubject = "Neue Kontaktanfrage: $subjectText - HexaHost.de"; +$emailBody = "Eine neue Kontaktanfrage wurde über das Kontaktformular eingegangen:\n\n"; +$emailBody .= "Name: $firstName $lastName\n"; +$emailBody .= "E-Mail: $email\n"; +if ($phone) $emailBody .= "Telefon: $phone\n"; +if ($company) $emailBody .= "Unternehmen: $company\n"; +$emailBody .= "Betreff: $subjectText\n"; +$emailBody .= "Newsletter-Anmeldung: " . ($newsletter ? 'Ja' : 'Nein') . "\n\n"; +$emailBody .= "Nachricht:\n$message\n\n"; +$emailBody .= "---\n"; +$emailBody .= "Diese E-Mail wurde automatisch generiert von hexahost.de\n"; +$emailBody .= "IP-Adresse: " . $_SERVER['REMOTE_ADDR'] . "\n"; +$emailBody .= "Zeitstempel: " . date('Y-m-d H:i:s') . "\n"; + +// Prepare HTML version +$htmlBody = " + + + + + Neue Kontaktanfrage - HexaHost.de + + + +
+

Neue Kontaktanfrage - HexaHost.de

+
+
+
+ Name: $firstName $lastName +
+
+ E-Mail: $email +
"; + +if ($phone) { + $htmlBody .= "
Telefon: $phone
"; +} + +if ($company) { + $htmlBody .= "
Unternehmen: $company
"; +} + +$htmlBody .= " +
+ Betreff: $subjectText +
+
+ Newsletter-Anmeldung: " . ($newsletter ? 'Ja' : 'Nein') . " +
+
+ Nachricht: +
" . nl2br($message) . "
+
+
+ + +"; + +// Send email using PHPMailer +try { + require_once 'vendor/autoload.php'; + + $mail = new PHPMailer\PHPMailer\PHPMailer(true); + + // Server settings + $mail->isSMTP(); + $mail->Host = SMTP_HOST; + $mail->SMTPAuth = true; + $mail->Username = SMTP_USERNAME; + $mail->Password = SMTP_PASSWORD; + $mail->SMTPSecure = PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_STARTTLS; + $mail->Port = SMTP_PORT; + $mail->CharSet = 'UTF-8'; + + // Anti-spam headers + $mail->addCustomHeader('X-Mailer', 'HexaHost.de Contact Form'); + $mail->addCustomHeader('X-Priority', '3'); + $mail->addCustomHeader('X-MSMail-Priority', 'Normal'); + $mail->addCustomHeader('Importance', 'Normal'); + $mail->addCustomHeader('X-Report-Abuse', 'Please report abuse here: abuse@hexahost.de'); + $mail->addCustomHeader('List-Unsubscribe', ''); + $mail->addCustomHeader('Precedence', 'bulk'); + + // Recipients + $mail->setFrom(SMTP_FROM_EMAIL, 'HexaHost.de Kontaktformular'); + $mail->addAddress(SMTP_TO_EMAIL, 'HexaHost Support'); + $mail->addReplyTo($email, "$firstName $lastName"); + + // Content + $mail->isHTML(true); + $mail->Subject = $emailSubject; + $mail->Body = $htmlBody; + $mail->AltBody = $emailBody; + + // Send email + $mail->send(); + + // Send confirmation to user + $userMail = new PHPMailer\PHPMailer\PHPMailer(true); + + // Server settings + $userMail->isSMTP(); + $userMail->Host = SMTP_HOST; + $userMail->SMTPAuth = true; + $userMail->Username = SMTP_USERNAME; + $userMail->Password = SMTP_PASSWORD; + $userMail->SMTPSecure = PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_STARTTLS; + $userMail->Port = SMTP_PORT; + $userMail->CharSet = 'UTF-8'; + + // Anti-spam headers for user confirmation + $userMail->addCustomHeader('X-Mailer', 'HexaHost.de Contact Form'); + $userMail->addCustomHeader('X-Priority', '3'); + $userMail->addCustomHeader('X-MSMail-Priority', 'Normal'); + $userMail->addCustomHeader('Importance', 'Normal'); + + // Recipients + $userMail->setFrom(SMTP_FROM_EMAIL, 'HexaHost.de'); + $userMail->addAddress($email, "$firstName $lastName"); + + // Content + $userMail->isHTML(true); + $userMail->Subject = 'Vielen Dank für Ihre Nachricht - HexaHost.de'; + $userMail->Body = " + + + + + Vielen Dank - HexaHost.de + + + +
+

Vielen Dank für Ihre Nachricht!

+
+
+

Hallo $firstName,

+

vielen Dank für Ihre Nachricht an HexaHost.de. Wir haben Ihre Anfrage erhalten und werden uns schnellstmöglich bei Ihnen melden.

+

Ihre Nachricht:
" . nl2br($message) . "

+

Unser Support-Team bearbeitet Ihre Anfrage und antwortet in der Regel innerhalb von 2-4 Stunden.

+

Bei dringenden Anliegen erreichen Sie uns auch telefonisch unter +49 851 1999 9999.

+
+ + + "; + + $userMail->AltBody = "Vielen Dank für Ihre Nachricht an HexaHost.de. Wir haben Ihre Anfrage erhalten und werden uns schnellstmöglich bei Ihnen melden."; + + $userMail->send(); + + // Success response + echo json_encode([ + 'success' => true, + 'message' => 'Ihre Nachricht wurde erfolgreich gesendet! Sie erhalten in Kürze eine Bestätigung per E-Mail.' + ]); + +} catch (Exception $e) { + error_log("Mail error: " . $e->getMessage()); + http_response_code(500); + echo json_encode([ + 'success' => false, + 'message' => 'Es gab ein Problem beim Senden Ihrer Nachricht. Bitte versuchen Sie es später erneut oder kontaktieren Sie uns direkt.' + ]); +} +?> \ No newline at end of file diff --git a/public/contact.html b/public/contact.html index de16c26..fe45a34 100644 --- a/public/contact.html +++ b/public/contact.html @@ -127,7 +127,8 @@ Senden Sie uns eine Nachricht - wir melden uns schnellstmöglich bei Ihnen

-
+ +
@@ -174,14 +175,14 @@