Crude Email Adddress CHecking

Discussion in 'Perl Misc' started by Bob, Sep 8, 2005.

  1. Bob

    Bob Guest

    OK, admitting up front that I know it's impossible to actually check
    email addresses for validity due to the possible valid address
    formats...

    I'm looking for a routine/chunk of code that will check email
    addresses for compliance with fairly standard formats i.e. it
    needs to be format, contain no spaces, etc.

    Anyone have a chunk or a pointer?

    Thanks,

    Bob (barely a perl programmer :)
     
    Bob, Sep 8, 2005
    #1
    1. Advertising

  2. Bob wrote:
    > OK, admitting up front that I know it's impossible to actually check
    > email addresses for validity due to the possible valid address
    > formats...
    >
    > I'm looking for a routine/chunk of code that will check email
    > addresses for compliance with fairly standard formats i.e. it
    > needs to be format, contain no spaces, etc.


    perldoc -q "valid mail"

    Steve
    --
    Stephen Hildrey
    E-mail: / Tel: +442071931337
    Jabber: / MSN:
     
    Stephen Hildrey, Sep 8, 2005
    #2
    1. Advertising

  3. Bob

    Paul Lalli Guest

    Bob wrote:
    > Note: The author of this message requested that it not be archived. This
    > message will be removed from Groups in 6 days (Sep 15, 8:08 am).


    That's rude. Questions and answers should be available to everyone
    searching this group later. Please don't do that again.

    > OK, admitting up front that I know it's impossible to actually check
    > email addresses for validity due to the possible valid address
    > formats...
    >
    > I'm looking for a routine/chunk of code that will check email
    > addresses for compliance with fairly standard formats i.e. it
    > needs to be format, contain no spaces, etc.


    It's time to ask yourself why you want to do this. You already *know*
    the inherent problems with "validating" email addresses. So what are
    you trying to accomplish? Do you really want to forbid those people
    with "non-standard" formats from using whatever service you're
    providing?

    Since you've stated that you want to match "fairly standard" formats,
    you're going to need to state exactly what formats you want to match.

    No spaces: $email =~ /^\S+$/
    something-at-something-dot-something: /^.+\@.+\..+$/

    For more information on why this is more complex than you're imagining,
    and why you probably shouldn't be doing it anyway:
    perldoc -q address
    OR
    http://perldoc.perl.org/perlfaq9.html#How-do-I-check-a-valid-mail-address?

    Paul Lalli
     
    Paul Lalli, Sep 8, 2005
    #3
  4. Bob

    Guest

    Paul Lalli wrote:
    > Bob wrote:
    > > Note: The author of this message requested that it not be archived. This
    > > message will be removed from Groups in 6 days (Sep 15, 8:08 am).

    >
    > That's rude. Questions and answers should be available to everyone
    > searching this group later. Please don't do that again.
    >
    > > OK, admitting up front that I know it's impossible to actually check
    > > email addresses for validity due to the possible valid address
    > > formats...
    > >
    > > I'm looking for a routine/chunk of code that will check email
    > > addresses for compliance with fairly standard formats i.e. it
    > > needs to be format, contain no spaces, etc.

    >
    > It's time to ask yourself why you want to do this. You already *know*
    > the inherent problems with "validating" email addresses. So what are
    > you trying to accomplish? Do you really want to forbid those people
    > with "non-standard" formats from using whatever service you're
    > providing?
    >
    > Since you've stated that you want to match "fairly standard" formats,
    > you're going to need to state exactly what formats you want to match.
    >
    > No spaces: $email =~ /^\S+$/
    > something-at-something-dot-something: /^.+\@.+\..+$/
    >
    > For more information on why this is more complex than you're imagining,
    > and why you probably shouldn't be doing it anyway:
    > perldoc -q address
    > OR
    > http://perldoc.perl.org/perlfaq9.html#How-do-I-check-a-valid-mail-address?
    >


    With all the usual caveats, Email::Valid may be an option.
    (It's been around quite a while -- I'm surprised there's no
    mention of it in the faq)

    --
    Charles DeRykkus
    around quite
     
    , Sep 10, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JD

    Checking email address

    JD, Sep 9, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    365
    Wayne Wengert
    Sep 9, 2005
  2. tkk
    Replies:
    5
    Views:
    361
    Chris Torek
    Jul 24, 2003
  3. Donnie Leen
    Replies:
    2
    Views:
    282
    Donnie Leen
    Dec 7, 2004
  4. F. Petitjean

    Crude statistics on the standard library

    F. Petitjean, Jan 31, 2005, in forum: Python
    Replies:
    2
    Views:
    345
    Fredrik Lundh
    Feb 2, 2005
  5. Jon Clements
    Replies:
    1
    Views:
    316
    Jorge Godoy
    Jul 27, 2006
Loading...

Share This Page