Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Finding if email addresses exist?

by cosmicperl (Chaplain)
on Jun 20, 2005 at 23:53 UTC ( #468519=perlquestion: print w/replies, xml ) Need Help??

cosmicperl has asked for the wisdom of the Perl Monks concerning the following question:

Hi All,
   This one has been puzzling me. I've noticed that my McAfee email secutriy feature tells me if I've sent an email and the user does not exist.
   I thought there must be a way of doing this with Perl. I guess it involves querying their mail server?

Any suggestions?

Thanks in advance.

Replies are listed 'Best First'.
Re: Finding if email addresses exist?
by jeyroz (Monk) on Jun 21, 2005 at 00:06 UTC

    Check out Email::Valid. It will actually check to see if the email address is well formed and if the domain exists (among many other features). The docs do mention that there is no way of determining whether an email address is "deliverable" without actually attempting to deliver a message.

    Hope this helps.

    author => jeyroz

      You can try this site . Is very good and very quick with Bulk email verification system and free verification system! Supports and api keys for registration forms like forums, newsletters. I have put there 80.000 emails and all were done!
Re: Finding if email addresses exist?
by biosysadmin (Deacon) on Jun 21, 2005 at 00:20 UTC
    Edit: I stand corrected. Don't do this, see explanation below. Thanks to all of the wise and cordial monks who have shown me the light on this topic, I could have very easily been flamed for making an unwise suggestion. :)

    As jeyroz said, Email::Valid is a good tool for a quick and dirty check. However, there's one more thing that you can do. Here's a quick snippet from a conversation with an e-mail server:

    [tex@smtp-client ~]$ telnet 25 Trying Connected to Escape character is '^]'. MAIL FROM: <> 250 Ok RCPT TO: <> 250 Ok
    So, at this point you can break the connection knowing you have a valid user. Here's the same conversation, slightly modified:
    [tex@smtp-client ~]$ telnet 25 Trying Connected to Escape character is '^]'. MAIL FROM: <> 250 Ok RCPT TO: <> 450 <>: Recipient address rejected: User + unknown in local recipient table
    So, if you write a program that speaks SMTP well, you can check a mail server for valid users without actually sending an e-mail. There's no guarantee that the server won't bounce the message after accepting it, but this just shows another trick beyond just using Email::Valid.
      And the FAQ also says that's unreliable. There are servers that say "sure, go ahead" for every address tested that way. And there are servers that say "no, we won't tell you, try sending first" for every email tested that way.

      Hence, you'll get both false positives and false negatives for such an approach, and far greater than your true reality hits.

      Hence, the FAQ's wisdom should be followed: you can't get there from here.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

      This is important enough, I feel compelled to re-iterate what Merlyn just said.

      Please do not validate email addresses by looking for mail server replies like this. The only thing you can rely upon by doing this is that what you are getting back is 100% unreliable.

      - dEvNuL

      Among the other reasons to not use this approach mentioned already is . . . Some spam fighting systems, mine included, monitor the maillog and quickly throw up a firewall rule blocking access to the system as soon as delivery is attempted to an invalid address. The object is to block dictionary attacks. The benefit is that your system no longer processes email destined for bogus addresses. There's a side effect of the sender being cut off after the first invalid address so any spam addressed to multiple adressees will never get delivered to legit addressees either.

      Be Appropriate && Follow Your Curiosity
        ...but a horrid problem for the lex-dysic... whose wife has personal and business accounts: fi_lname@work... and lname_fi@personal...

        So if I botch an address with lname_fi@work..., her server there is gonna, forever afterward, bounce (or worse, simply dev\nul it) until she cleans my IP out of the filter?

        Agreed (I'D YELL AGREEMENT! but that would be impolite... but isn't that solution rather draconian (or, alternately, is there something here I don't understand)?

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://468519]
Approved by Thilosophy
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2023-10-01 14:41 GMT
Find Nodes?
    Voting Booth?

    No recent polls found