" ; // Check, ob für Domain (mindestens) ein MX-Record existiert if ($ret === false ) { // MX-Record(s) abholen getmxrr($domain, $mx_records, $mx_weight); $mxs =[]; // Array zusammenstellen für Sortierung for($i=0;$i 0) { asort ($mxs); // Erforderliche Daten stehen im Key => nach Array "records" schreiben $records = array_keys($mxs); } if (count($records) == 0) { $ret = true; } } return ($ret); } function download_blocklist($file_path) { // Alternative Liste: $url = 'https://raw.githubusercontent.com/disposable-email-domains/disposable-email-domains/main/disposable_email_blocklist.conf'; $url = 'https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.txt'; echo "Lade Blocklist herunter...\n"; $content = file_get_contents($url); if ($content === false) { die("FEHLER: Konnte Blocklist nicht herunterladen von: $url\n"); } // Zusätzliche lokale Liste der nicht zugelassenen Domains $localContent = ''; if (file_exists(__DIR__ . '/localdomains.conf')) { $localContent = file_get_contents(__DIR__ ."/localdomains.conf"); } // Listen kombinieren $content = $content ."\n" .$localContent; if (file_put_contents($file_path, $content) === false) { die("FEHLER: Konnte Blocklist nicht speichern: $file_path\n"); } echo "Blocklist erfolgreich heruntergeladen: $file_path\n"; } function update_blocklist_if_needed($blocklist_path = null, $max_age_hours = 1) { if (!$blocklist_path) { $blocklist_path = __DIR__ . '/disposable_email_blocklist.conf'; } // Prüfe ob Datei existiert und wie alt sie ist if (!file_exists($blocklist_path)) { download_blocklist($blocklist_path); return true; } $file_age = time() - filemtime($blocklist_path); $max_age_seconds = $max_age_hours * 3600; if ($file_age > $max_age_seconds) { echo "Blocklist ist " . round($file_age / 3600, 1) . " Stunden alt. Aktualisiere...\n"; download_blocklist($blocklist_path); return true; } return false; } function filter_disposable_emails($emails, $blocklist_path = null) { $valid_emails = array(); foreach ($emails as $email) { if (!is_disposable_email($email, $blocklist_path)) { $valid_emails[] = $email; } } return $valid_emails; } function get_email_domain($email) { $email_parts = explode('@', trim($email)); return count($email_parts) === 2 ? strtolower($email_parts[1]) : ''; } function validate_email_form($email) { // Umfassende Validierung für Formulare if (empty($email)) { return array('valid' => false, 'error' => 'E-Mail-Adresse ist erforderlich'); } if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { return array('valid' => false, 'error' => 'Ungültige E-Mail-Adresse'); } if (is_disposable_email($email)) { return array('valid' => false, 'error' => 'Wegwerf-E-Mail-Adressen sind nicht erlaubt'); } return array('valid' => true, 'error' => null); } // =========================================== // BEISPIELE: // =========================================== // Test-E-Mails $test_emails = array( 'user@gmail.com', // Legitim 'test@mailinator.com', // Disposable 'demo@10minutemail.com', // Disposable 'contact@tempmail.org', // Disposable 'roland.keck@t-onlin.de', 'roland.keck@conlicom.de' // Legitim ); // Blocklist aktualisieren falls nötig (alle 24h) $updated = update_blocklist_if_needed(); if ($updated) { echo "Blocklist wurde aktualisiert.
\n"; } echo "

E-Mail-Validierung:

\n"; foreach ($test_emails as $email) { if (is_disposable_email($email)) { echo "❌ BLOCKIERT: $email ist eine Wegwerf-Adresse
\n"; } else { echo "✅ ERLAUBT: $email
\n"; } } // Bulk-Filterung //echo "

Gefilterte Liste:

\n"; //$valid_emails = filter_disposable_emails($test_emails); //echo "Gültige E-Mails: " . implode(', ', $valid_emails) . "
\n"; // =========================================== // FORMULAR-INTEGRATION: // =========================================== // In deinem Registrierungsformular: if (isset($_POST['email'])) { $email = trim($_POST['email']); $validation = validate_email_form($email); if ($validation['valid']) { echo "✅ E-Mail-Adresse ist gültig: $email
\n"; // Hier: Registrierung fortsetzen... } else { echo "❌ " . $validation['error'] . "
\n"; } } ?>
\n"; echo "- Anzahl Domains: $count
\n"; echo "- Alter: $age_hours Stunden
\n"; echo "- Datei: $blocklist_path
\n"; } else { echo "Blocklist-Datei existiert noch nicht.
\n"; } } // Zeige Info über die Blocklist echo "

Blocklist-Status:

\n"; show_blocklist_info(); ?>