my code stock.com

Philip Grassegger

Validation - Fake-Mails
by Philip Grassegger

Sie wollen überprüfen, ob ein User eine gültige Trash-eMail verwendet hat? Kein Problem: Diese PHP-Funktion hilft Ihnen.

Snippet options

Download: Download snippet as validation-fake-mails.txt.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

function check_trash_mail($email) {
 
 
    $xml_source = 'http://www.mogelmail.de/mogelmails.xml';
    $xml_str = file_get_contents($xml_source);
 
 
    $xml = new SimpleXMLElement($xml_str);
    $domains = array();
         
        //Domains in Array schreiben
    foreach($xml->domainitem as $domain) {
        $domains[] = (string)$domain->domain;
    }
        
        // Host der E-Mail-Adresse herausfinden
    $email_host = substr($email, strrpos($email, '@')+1, strlen($email));
         
        // Prüfen, ob E-Mail auf Blacklist steht
    return in_array($email_host, $domains);
}

if(isset($_GET['email'])) {
   if(check_trash_mail($_GET['email'])) {
    echo 'Diese E-Mail stammt von einem Trashmail Anbieter!';
   } else {
    echo 'Keine Trashmail!';
   }
}

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.