Re: Check for existence of mail address
| From: | TR Shaw | Date: | Tue, 26 Oct 2010 14:38:10 +0000 |
| Subject: | Re: Check for existence of mail address | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-309080@lists.php.net to get a copy of this message | ||
On Oct 26, 2010, at 8:49 AM, TR Shaw wrote:
> On Oct 25, 2010, at 6:38 PM, webdev@blaettner.com wrote:
>
>> Hi, folks,
>>
>> I'm wondering how to checking existence of a given
>> mail address like foo@bar.com .
>>
>> At 1st I tried:
>>
>> if f (filter_var ($maddr, FILTER_VALIDATE_EMAIL) === false) {
>> /* some sort of error handling code here */
>> }
>>
>> where $maddr is the address to be checked.
>> But this checks only syntax.. :-(
>>
>> Is there any other function which checks whether this
>> address really exists?
>>
>> And, of course, I want to avoid sending a test mail just
>> for checking :-)
>>
>> Many THX in advance for suggestions, pointers...
>>
>
> Rolf,
>
> Since most mailservers have disabled VRFY long ago due to spammers and other miscreants.
>
> Easiest way is to use class.smtp.php form phpmailer using the following:
>
> $smtp = new SMTP
> if (empty($smtp->Connect())) return false; // Connect failure
> if (empty($smtp->Hello("yourmailerver.com")) return false; //Maybe not a mailserve
> if(empty($smtp->Recipient($to))) return false; //No such user
> $smtp->Close(); // Found user so abort transaction.
> return true;
>
> Tom
>
>
PS I didn't cover greylisting in the above.
PPS But why? If you are running a mailing list you need to generate different mail froms and deal
with rejections that way . It is spammy if you try to use the above to clean a list and will
probably cause you to be black listed. I know I set my server list blacklist too many of these.
Tom