Email-Adresse auf Gültigkeit prüfen?

  • Hallo,


    ich bin gerade beim Video-Workshop 96 - anwendung-is-mail.


    Frage: Wie kann ich die Email-Adresse vor dem Absenden auf Gültigkeit prüfen?


    :wink: Lg. Adolpho

  • Sorry,
    mein Fehler.
    Ich meinte eigentlich, ob es eine Möglichkeit gibt, die Emailadresse vor dem Absenden auf ihre Existenz zu überprüfen.
    Lg.
    :wink: Adolpho

  • Ne andere Möglichkeit ist immer, so eine Art Aktivierungsmail zu verschicken. Bevor derjenige nicht auf den Link in der Mail geklickt hat, wird was auch immer du machen willst nicht bestätigt und es kann nichts mehr von der IP-Adresse abgesendet werden..


    LG

  • Hallo lauras,
    anscheinend gibt es doch eine Möglichkeit ein Email auf ihre Existenz zu überprüfen.


    Folgenden Code habe ich im Internet gefunden:


    PHP
    <span class="syntaxdefault"><?php<br />function CheckEmail</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$email</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{</span><span class="syntaxdefault">    list</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$user</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> $domain</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> split</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"@"</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> $email</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 2</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">    getmxrr</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$domain</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> $mxlist</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">     $return </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> array</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">false</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">"No email."</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">     foreach</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$mxlist as $mx</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">     </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">       $fp </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> fsockopen</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$mx</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 25</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> $errno</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> $errstr</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 20</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">     if</span><span class="syntaxkeyword">(!</span><span class="syntaxdefault">$fp</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> continue</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">     socket_set_blocking</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$fp</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> false</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">      $s </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> 0</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">      $c </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> 0</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">      $out </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">""</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">      do </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">        $out </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> fgets</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$fp</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 2500</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">      if</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">ereg</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"^220"</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> $out</span><span class="syntaxkeyword">))</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">        $s </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> 0</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">        $out </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">""</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">        $c</span><span class="syntaxkeyword">++;<br /></span><span class="syntaxdefault">        </span><span class="syntaxkeyword">}</span><span class="syntaxdefault"> else<br />        </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">          if</span><span class="syntaxkeyword">((</span><span class="syntaxdefault">$c</span><span class="syntaxkeyword">></span><span class="syntaxdefault">0</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">&&</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$out</span><span class="syntaxkeyword">==</span><span class="syntaxstring">""</span><span class="syntaxkeyword">))</span><span class="syntaxdefault"> break</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">           else $s</span><span class="syntaxkeyword">++;<br /></span><span class="syntaxdefault">        </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">        if</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$s</span><span class="syntaxkeyword">==</span><span class="syntaxdefault">9999</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> break</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">        </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">        while</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$out</span><span class="syntaxkeyword">==</span><span class="syntaxstring">""</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">        socket_set_blocking</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$fp</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> true</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">        fputs</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$fp</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">"HELO\n"</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">        $out </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> fgets</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$fp</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 3000</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">        fputs</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$fp</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">"MAIL FROM: user@news-user.com\n"</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">        $out </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> fgets</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$fp</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 3000</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">        fputs</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$fp</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">"RCPT TO: $email\n"</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">        $out </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> fgets</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$fp</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 3000</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">        if</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">ereg</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"^250"</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> $out</span><span class="syntaxkeyword">))<br /></span><span class="syntaxdefault">        </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">          $return </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> array</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">true</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$out</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">        </span><span class="syntaxkeyword">}</span><span class="syntaxdefault"> else<br />        </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">          $return </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> array</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">false</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$out</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">        </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">        fputs</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$fp</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">"quit\n"</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">        fclose</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$fp</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">        if</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$return</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">])</span><span class="syntaxdefault"> break</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">        </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">        return $return</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">        </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">        $ret </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> CheckEMail</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"user@news-user.com"</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">        echo</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$ret</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxstring">" "</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$ret</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">]);<br /><br /></span><span class="syntaxdefault">?></span>


    Dieser Code ist in Arbeit.


    Lg.
    :wink: adolpho

  • Probiers aus ;)


    Also es fehlt schonmal ein Anführungszeichen:

    PHP
    <span class="syntaxdefault"><br />$ret </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">CheckEMail</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"user@news-user.com);<br /></span>


    (Ganz am Ende, danach ist alles rot)

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!