Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can't just regexp match an email address against a short regexp pattern if you want to accept all validly formed email addresses and reject all non-valid one. Use a parser (<a href="http://code.iamcal.com/php/rfc822/" rel="nofollow noreferrer">1</a>, <a href="http://www.dominicsayers.com/isemail/" rel="nofollow noreferrer">2</a>) that actually implement against the relevant RFCs to check for validity.</p> <p>Other things you can do is checking HTTP_REFERER to make sure the request came from within your domain as <em>Chacha102</em> already mentioned. Just note that not all agent send HTTP_REFERER, and that it can be optionally turned off or faked by users.</p> <p>If you want to go the extra mile to make sure they are giving you a valid email address, you can check for existing DNS record for mail servers at the domain specified (A, MX, or AAAA). And on top of that, you can do callback verification. That's where you connect to the mail server, tell it you want to send to this email address and see if they say OK.</p> <p>For callback verification, you should note greylisting servers say OK to everything so even that is not a guarantee. Here's some code I used when I needed such a script. It's a patch onto the parser from (<a href="http://code.iamcal.com/php/rfc822/" rel="nofollow noreferrer">1</a>).</p> <pre><code> # # Email callback verification # Based on http://uk2.php.net/manual/en/function.getmxrr.php # if (strlen($bits['domain-literal'])){ $records = array($bits['domain-literal']); }elseif (!getmxrr($bits['domain'], $mx_records, $mx_weight)){ $records = array($bits['domain']); }else{ $mxs = array(); for ($i = 0; $i &lt; count($mx_records); $i++){ $mxs[$mx_records[$i]] = $mx_weight[$i]; } asort($mxs); $records = array_keys($mxs); } $user_okay = false; for ($j = 0; $j &lt; count($records) &amp;&amp; !$user_okay; $j++){ $fp = @fsockopen($records[$j], 25, $errno, $errstr, 2); if($fp){ $ms_resp = ""; $ms_resp .= send_command($fp, "HELO ******.com"); $ms_resp .= send_command($fp, "MAIL FROM:&lt;&gt;"); $rcpt_text = send_command($fp, "RCPT TO:&lt;" . $email . "&gt;"); $ms_resp .= $rcpt_text; $ms_code = intval(substr($rcpt_text, 0, 3)); if ($ms_code == 250 || $ms_code == 451){ // Accept all user account on greylisting server $user_okay = true; } $ms_resp .= send_command($fp, "QUIT"); fclose($fp); } } return $user_okay ? 1 : 0; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload