MikeKlemin
MikeKlemin

Reputation: 959

Veryfing emails perl with, say Mail::VRFY

I am trying to verify couple of emails. The thing is that I have different results with http://verify-email.org/ and Mail::VRFY, where 1st is more close to reality.

Yes I know that checking the existing user is unreliable, but still.

What I receive is

 One Advertised SMTP server permanently refused mail

Or if I try with Mail::CheckUser

 No such user

Could it be that the server is refusing my request by IP filtering? Like if I run my script from suspicious region I get refused?

And if it is, how can overcome this... Doesn’t looks as simple as LWP with proxies :-(

Upvotes: 1

Views: 396

Answers (1)

Schwern
Schwern

Reputation: 165198

There is no good way to verify that an email address exists without attempting delivery. verify-email.org, Mail::CheckUser and Mail::VRFY appear to be using the same technique, sending MAIL FROM and RCPT TO and then closing the connection after hearing the response but before sending the actual mail.

Sending an email has evolved into complicated measures, counter-measures, counter-counter-measures, and so on... between spammers and mail servers. verify-email.org likely knows how to do this dance which can include things such as special setup of the MX and DNS records. J.RANDOM.COMPUTER.net doesn't have that, and if you're doing it from a home network you're probably already on a blacklist, not because you've done anything wrong, it's just assumed. Mail::VRFY and Mail::CheckUser probably do not know how to look like legit mail servers.

Mail::CheckUser is not being entirely accurate with you when it says No such user. A peak at the code in Mail::CheckUser::check_user_on_host() shows why.

    if($code == 550 or $code == 551 or $code == 553) {
        return _result(CU_UNKNOWN_USER, 'no such user');
    }

Those SMTP codes are...

  • 550 - The requested command failed because the user's mailbox was unavailable (for example because it was not found, or because the command was rejected for policy reasons).
  • 551 - The recipient is not local to the server. The server then gives a forward address to try.
  • 553 - The command was aborted because the mailbox name is invalid.

Mail::VRFY is doing the same thing but for all 500 codes.

}elsif($rt[-1] =~ /^5\d{2}/){
    # host rejected
    return 7;
}

Where 7 is "One Advertised SMTP server permanently refused mail."

Meanwhile, Email::Valid will validate the syntax and validate the domain exists.

Your best bet is to either use a pre-existing external service, or get full access to a real mail server you can control, or to do all the work to set up a real mail server.

Upvotes: 1

Related Questions