mirror of
https://git.hexahost.dev/smueller/HexaHost-Frontend.git
synced 2026-06-02 08:08:43 +00:00
134 lines
2.7 KiB
PHP
134 lines
2.7 KiB
PHP
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
define('SMTP_FROM_EMAIL', 'kontakt@hexahost.de');
|
|
define('SMTP_TO_EMAIL', 'info@hexahost.de');
|
|
|
|
|
|
define('ENABLE_CSRF_PROTECTION', true);
|
|
define('ENABLE_RATE_LIMITING', true);
|
|
define('MAX_REQUESTS_PER_HOUR', 10);
|
|
|
|
|
|
define('ENABLE_SPAM_PROTECTION', true);
|
|
define('MAX_MESSAGE_LENGTH', 5000);
|
|
define('MIN_MESSAGE_LENGTH', 10);
|
|
|
|
|
|
define('DEBUG_MODE', false);
|
|
define('LOG_EMAILS', true);
|
|
|
|
|
|
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'
|
|
]);
|
|
|
|
|
|
define('ALLOWED_EMAIL_DOMAINS', [
|
|
|
|
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
define('BLACKLISTED_EMAILS', [
|
|
|
|
|
|
]);
|
|
|
|
|
|
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');
|
|
}
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
|
|
function isValidEmail($email) {
|
|
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
return false;
|
|
}
|
|
|
|
|
|
if (in_array($email, BLACKLISTED_EMAILS)) {
|
|
return false;
|
|
}
|
|
|
|
|
|
if (!empty(ALLOWED_EMAIL_DOMAINS)) {
|
|
$domain = substr(strrchr($email, "@"), 1);
|
|
if (!in_array($domain, ALLOWED_EMAIL_DOMAINS)) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getHexaHostConfig($key = null) {
|
|
$config = [
|
|
|
|
'from_email' => SMTP_FROM_EMAIL,
|
|
'from_name' => 'HexaHost.de Kontaktformular',
|
|
'to_email' => SMTP_TO_EMAIL,
|
|
'to_name' => 'HexaHost Support',
|
|
|
|
|
|
'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_mode' => DEBUG_MODE,
|
|
'log_errors' => LOG_EMAILS,
|
|
];
|
|
|
|
if ($key === null) {
|
|
return $config;
|
|
}
|
|
|
|
return $config[$key] ?? null;
|
|
}
|
|
?>
|