mirror of
https://git.hexahost.dev/smueller/HexaHost-Frontend.git
synced 2026-06-02 07:48:43 +00:00
134 lines
3.9 KiB
PHP
134 lines
3.9 KiB
PHP
<?php
|
|
/**
|
|
* HexaHost.de Mail Configuration
|
|
*
|
|
* Dieses Projekt versendet E-Mails nativ über PHP mail().
|
|
* Es sind keine externen Bibliotheken oder Composer-Installationen erforderlich.
|
|
*/
|
|
|
|
// E-Mail Adressen
|
|
define('SMTP_FROM_EMAIL', 'kontakt@hexahost.de'); // Absender-E-Mail
|
|
define('SMTP_TO_EMAIL', 'info@hexahost.de'); // Empfänger-E-Mail für Kontaktformular
|
|
|
|
// Sicherheitseinstellungen
|
|
define('ENABLE_CSRF_PROTECTION', true); // CSRF-Schutz aktivieren
|
|
define('ENABLE_RATE_LIMITING', true); // Rate-Limiting aktivieren
|
|
define('MAX_REQUESTS_PER_HOUR', 10); // Max. Anfragen pro Stunde
|
|
|
|
// Spam-Schutz Einstellungen
|
|
define('ENABLE_SPAM_PROTECTION', true); // Spam-Schutz aktivieren
|
|
define('MAX_MESSAGE_LENGTH', 5000); // Max. Nachrichtenlänge
|
|
define('MIN_MESSAGE_LENGTH', 10); // Min. Nachrichtenlänge
|
|
|
|
// Debug-Einstellungen (nur für Entwicklung)
|
|
define('DEBUG_MODE', false); // Debug-Modus (true/false)
|
|
define('LOG_EMAILS', true); // E-Mails loggen (true/false)
|
|
|
|
// Zusätzliche Sicherheitsheader
|
|
define('ADDITIONAL_HEADERS', [
|
|
'X-Mailer' => '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' => '<mailto:unsubscribe@hexahost.de>',
|
|
'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'
|
|
]);
|
|
|
|
// Ü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 = [
|
|
// 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;
|
|
}
|
|
?>
|