Jump to content

email exists: getmxrr


alpine

Recommended Posts

Being tired of bogus email-signups i'm thinking of doing a real-host check in some of my services.

Just to be clear, this isn't about checking valid email format (i check for that already) but rather a lookup function to verify a real and working host.

After reading back and forth in the manual i sticked on this example: http://no2.php.net/manual/en/function.getmxrr.php#64117

Seems to be running ok in most cases but i still cannot get a true result from it on a few norwegian hostnames i test it against.


Anyone that has already wandered these wods that can give me the path to an ok solution on this issue ?
Link to comment
Share on other sites

this is what I use, dont know if it has a problem with norwegian sites:
[code]function isemailvalid($emailaddr) {
    //tests for valid email address
    if( (!preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/', $emailaddr)) &&
        (!preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})  (\]?)$/', $emailaddr)) ) {
        return FALSE;
    }
    list($mailusername, $mailDomain) = split("@", $emailaddr);
    if(checkdnsrr($mailDomain, 'MX') ) return TRUE;
    if(checkdnsrr($mailDomain, 'A') ) return TRUE;
    if(checkdnsrr($mailDomain, 'CNAME') ) return TRUE;
    return FALSE;
} [/code]
Link to comment
Share on other sites

Thanks mainewoods,

It seems to have issues (false) on some hostnames, but if i check on all types (A, MX, NS, SOA, PTR, CNAME, AAAA, A6, SRV, NAPTR, ANY) it works on all tested adresses.

Seems that checkdnsrr perhaps is the way to settle with this for now.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.