|
Posted by Curt Zirzow on 11/17/05 08:16
On Wed, Nov 16, 2005 at 07:39:28AM -0000, George Pitcher wrote:
> I grabbed the following from a web-published article (sorry, can't remember
> where):
There a few things wrong with it as well.
>
> function validate_email($email) {
> if(preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+(
> \.[a-zA-Z0-9_-] +)+$/" , $email)){
Problem #1
- with those spaces in the expression i would assume it really
needs to have the /x modifier, i would hardly thing that anyone
will type:
' c zirzow @ gmail .c '
- it doesn't consider emails like foo@foo.us.gov
I think there was a 300+ line regex to catch all cases, posted
earlier.
> list($username,$domain)=split('@',$email);
> if(!customCheckDnsrr($domain)){
> ...
> function customCheckDnsrr($host,$recType='') {
> if(!empty($host)) {
> if($recType=='') $recType="MX";
> exec("nslookup -type=$recType $host",$output);
> ...
Problem #2
- an MX record isn't required to deliver email. Try a:
nslookup -type=MX zirzow.dyndns.org then send an email to
curt@zirzow.dyndns.org, i will get it.
> foreach($output as $line) {
> if(preg_match("/^$host/", $line)) {
Problem #3
- MX hosts dont *have* to resolve to the same host it is doing
mail for, it generally does resolve that way, in most cases.
>
> Never tested this, so can't comment on usefulness.
Uh.. well, i hope problems 1-3 should contribute to its (un)usefulness.
Curt.
--
[Back to original message]
|