'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; } /** * Hilfsfunktion zum Abrufen der Konfiguration als Array * Kompatibilität mit contact-handler.php * * @param string|null $key Optional: einzelner Schlüssel * @return mixed Konfigurationsarray oder einzelner Wert */ function getHexaHostConfig($key = null) { $config = [ // SMTP Server-Einstellungen 'smtp_host' => SMTP_HOST, 'smtp_port' => SMTP_PORT, 'smtp_username' => SMTP_USERNAME, 'smtp_password' => SMTP_PASSWORD, 'smtp_encryption' => 'tls', // Absender/Empfänger 'from_email' => SMTP_FROM_EMAIL, 'from_name' => 'HexaHost.de Kontaktformular', 'to_email' => SMTP_TO_EMAIL, 'to_name' => 'HexaHost Support', // Sicherheit 'max_requests_per_hour' => MAX_REQUESTS_PER_HOUR, 'honeypot_field' => 'website', 'enable_csrf' => ENABLE_CSRF_PROTECTION, 'min_message_length' => MIN_MESSAGE_LENGTH, 'max_message_length' => MAX_MESSAGE_LENGTH, // Debug 'debug_mode' => DEBUG_MODE, 'log_errors' => LOG_EMAILS, ]; if ($key === null) { return $config; } return $config[$key] ?? null; } ?>