kostenloser Webspace werbefrei: lima-city


existenz von E-Mailadressen abfragen

lima-cityForumProgrammiersprachenPHP, MySQL & .htaccess

  1. Autor dieses Themas

    mysave

    Kostenloser Webspace von mysave, auf Homepage erstellen warten

    mysave hat kostenlosen Webspace.

    Hi,
    ich wollte mal wissen ob es möglich ist mittels PHP abzufragen ob eine E-Mailadresse existiert oder nicht und wenn es möglich ist würde mich auch sehr interessieren wie.
  2. Diskutiere mit und stelle Fragen: Jetzt kostenlos anmelden!

    lima-city: Gratis werbefreier Webspace für deine eigene Homepage

  3. thomasba

    Co-Admin Kostenloser Webspace von thomasba

    thomasba hat kostenlosen Webspace.


    Hi,
    ich wollte mal wissen ob es möglich ist mittels PHP abzufragen ob eine E-Mailadresse existiert oder nicht und wenn es möglich ist würde mich auch sehr interessieren wie.


    Das ist nicht möglich, eine Möglichkeit wäre eine Art Bestätigungslink an die E-Mail Adresse zu senden, eine andere Möglichkeit gibt es meines Wissens nach nicht.
  4. Autor dieses Themas

    mysave

    Kostenloser Webspace von mysave, auf Homepage erstellen warten

    mysave hat kostenlosen Webspace.

    OK, danke für die schnelle Antwort.
  5. o**s

    Es ist übrigens sehr gut, dass es diese Möglichkeit nicht gibt. Anders wäre die Möglichkeit für Spam um vielfaches erleichtert, denn es würden nicht mehr Sendeversuche an nicht-existente E-Mail-Adressen unternommen.
  6. lordoflima

    Admin Kostenloser Webspace von lordoflima

    lordoflima hat kostenlosen Webspace.

    Doch, das kann man machen.

    Man verbindet sich dabei auf den Port 25 der IP des MX-Records für die Domain, sendet das HELO, dann das MAIL FROM und dann das RCPT TO. Dann kommt entweder Ok, also eine 2XXer-Meldung, oder eine anderene, 4XX oder 5XX, die einen Fehler angibt, wenn das Postfach nicht existiert.

    Was dabei allerdings nicht beachtet wird: ist derjenige, der die Adresse angibt auch derjenige, der Zugriff auf das Postfach besitzt?
  7. Hm, ich bin da jetzt kein Spezialist, aber wenn mein Mail-Server eine Email-Adresse nicht erreicht, bringt der eine Fehlermeldung. (Wobei das glaube ich viel mehr an dem Empfangs-Server liegt)

    Wenn man diese nun abfängt, könnte man doch ggf. schon eine "überprüfung" auf die Existenz durchführen, oder?

    EDIT:


    Man verbindet sich dabei auf den Port 25 der IP des MX-Records für die Domain, sendet das HELO, dann das MAIL FROM und dann das RCPT TO. Dann kommt entweder Ok, also eine 2XXer-Meldung, oder eine anderene, 4XX oder 5XX, die einen Fehler angibt, wenn das Postfach nicht existiert.


    Genau sowas meinte ich ;)

    Beitrag geändert: 8.8.2008 9:24:05 von nerdinator
  8. Natürlich geht das, ich nutze es um zu überprüfen ob meine eigene Info-/Support-Email-Adresse online ist. Falls der Server nicht zu erreichen ist, wird das gemeldet.

    http://tof-devil.lima-city.de/moon.studios/?link=support

    Man kann damit aber natürlich auch überprüfen ob eine eMail-Adresse überhaupt existiert. Problem ist nur. Wenn du zum Beispiel eine GMX-eMail-Adresse auf vorhandenheit prüfen willst und der GMX-Mailserver ist gerade ausgefallen, dann existiert die eMail-Adresse natürlich nicht.


    Diese PHP-Funktion prüft ob auf einem eMail Server die eMail-Adresse existiert. Es wird eine Verbindung zum Server über den Port 25 aufgebaut.


    This PHP function checks if an email address is valid. By default it will only do syntax checking with a regex, but it can also be configured to do a MX record check. I have expanded the function so that it can also be configured to verify the address via an SMTP probe.

    It will give an error in these situations:

    * A 5xx SMTP response code is encountered
    * None of the mailservers can be contacted
    * No usable DNS records are found
    * The script take more than a certain amount of time (mostly transient errors)
    <?php
    /* 
       $Id: VerifyEmailAddress.php 8 2008-01-13 22:51:10Z visser $
       
       Email address verification with SMTP probes
       Dick Visser <dick@tienhuis.nl>
    
       INTRODUCTION
    
       This function tries to verify an email address using several tehniques,
       depending on the configuration. 
    
       Arguments that are needed:
    
       $email (string)
       The address you are trying to verify
    
       $domainCheck (boolean)
       Check if any DNS MX records exist for domain part
    
       $verify (boolean)
       Use SMTP verify probes to see if the address is deliverable.
    
       $probe_address (string)
       This is the email address that is used as FROM address in outgoing
       probes. Make sure this address exists so that in the event that the
       other side does probing too this will work.
       
       $helo_address (string)
       This should be the hostname of the machine that runs this site.
    
       $return_errors (boolean)
       By default, no errors are returned. This means that the function will evaluate
       to TRUE if no errors are found, and false in case of errors. It is not possible
       to return those errors, because returning something would be a TRUE.
       When $return_errors is set, the function will return FALSE if the address
       passes the tests. If it does not validate, an array with errors is returned.
    
    
       A global variable $debug can be set to display all the steps.
    
    
       EXAMPLES
    
       Use more options to get better checking.
       Check only by syntax:  validateEmail('dick@tienhuis.nl')
       Check syntax + DNS MX records: validateEmail('dick@tienhuis.nl', true);   
       Check syntax + DNS records + SMTP probe:
       validateEmail('dick@tienhuis.nl', true, true, 'postmaster@tienhuis.nl', 'outkast.tienhuis.nl');
    
    
       WARNING
     
       This function works for now, but it may well break in the future.
    
    */
    function validateEmail($email, $domainCheck = false, $verify = false, $probe_address='', $helo_address='', $return_errors=false) {
        global $debug;
        $server_timeout = 180; # timeout in seconds. Some servers deliberately wait a while (tarpitting)
        if($debug) {echo "<pre>";}
        # Check email syntax with regex
        if (preg_match('/^([a-zA-Z0-9._+-]+)@(([?)[a-zA-Z0-9-.]+.([a-zA-Z]{2,7}|[0-9]{1,3})(]?))$/', $email, $matches)) {
            $user = $matches[1];
            $domain = $matches[2];
            # Check availability of DNS MX records
            if ($domainCheck && function_exists('checkdnsrr')) {
                # Construct array of available mailservers
                if(getmxrr($domain, $mxhosts, $mxweight)) {
                    for($i=0;$i<count($mxhosts);$i++){
                        $mxs[$mxhosts[$i]] = $mxweight[$i];
                    }
                    asort($mxs);
                    $mailers = array_keys($mxs);
                } elseif(checkdnsrr($domain, 'A')) {
                    $mailers[0] = gethostbyname($domain);
                } else {
                    $mailers=array();
                }
                $total = count($mailers);
                # Query each mailserver
                if($total > 0 && $verify) {
                    # Check if mailers accept mail
                    for($n=0; $n < $total; $n++) {
                        # Check if socket can be opened
                        if($debug) { echo "Checking server $mailers[$n]...n";}
                        $connect_timeout = $server_timeout;
                        $errno = 0;
                        $errstr = 0;
                        # Try to open up socket
                        if($sock = @fsockopen($mailers[$n], 25, $errno , $errstr, $connect_timeout)) {
                            $response = fgets($sock);
                            if($debug) {echo "Opening up socket to $mailers[$n]... Succes!n";}
                            stream_set_timeout($sock, 30);
                            $meta = stream_get_meta_data($sock);
                            if($debug) { echo "$mailers[$n] replied: $responsen";}
                            $cmds = array(
                                "HELO $helo_address",
                                "MAIL FROM: <$probe_address>",
                                "RCPT TO: <$email>",
                                "QUIT",
                            );
                            # Hard error on connect -> break out
                            # Error means 'any reply that does not start with 2xx '
                            if(!$meta['timed_out'] && !preg_match('/^2dd[ -]/', $response)) {
                                $error = "Error: $mailers[$n] said: $responsen";
                                break;
                            }
                            foreach($cmds as $cmd) {
                                $before = microtime(true);
                                fputs($sock, "$cmdrn");
                                $response = fgets($sock, 4096);
                                $t = 1000*(microtime(true)-$before);
                                if($debug) {echo htmlentities("$cmdn$response") . "(" . sprintf('%.2f', $t) . " ms)n";}
                                if(!$meta['timed_out'] && preg_match('/^5dd[ -]/', $response)) {
                                    $error = "Unverified address: $mailers[$n] said: $response";
                                    break 2;
                                }
                            }
                            fclose($sock);
                            if($debug) { echo "Succesful communication with $mailers[$n], no hard errors, assuming OK";}
                            break;
                        } elseif($n == $total-1) {
                            $error = "None of the mailservers listed for $domain could be contacted";
                        }
                    }
                } elseif($total <= 0) {
                    $error = "No usable DNS records found for domain '$domain'";
                }
            }
        } else {
            $error = 'Address syntax not correct';
        }
        if($debug) { echo "</pre>";}
        
        if($return_errors) {
            # Give back details about the error(s).
            # Return FALSE if there are no errors.
            if(isset($error)) return htmlentities($error); else return false;
        } else {
            # 'Old' behaviour, simple to understand
            if(isset($error)) return false; else return true;
        }
    }
    
    ?>


    Website des Erstellers mit Vorführungs-Demo:
    http://www.tienhuis.nl/php-email-address-validation-with-verify-probe

    MfG tof-devil

    PS: Einen Bestätigungslink per eMail zu versendet schadet trozdem nicht. So stellst du sicher, dass der Jenige der sich irgendwo registriert auch der ist dem die eMail-Adresse gehört.

    Beitrag geändert: 8.8.2008 11:13:06 von tof-devil
  9. o**s

    Wenn ich mich richtig informiert habe, antworten MailServer mit Spamschutz nicht auf E-Mails, die in der Blacklist stehen. Sie senden auch keine Fehlermeldungen zurück.
  10. Diskutiere mit und stelle Fragen: Jetzt kostenlos anmelden!

    lima-city: Gratis werbefreier Webspace für deine eigene Homepage

Dir gefällt dieses Thema?

Über lima-city

Login zum Webhosting ohne Werbung!