Verify an e-mail-adress - syntax and dns

Discussion in 'Python' started by Ingo Linkweiler, Sep 24, 2006.

  1. Has anyone a function/script to verify an e-mail-address?

    It should:
    a) check the syntax
    b) verify an existing mailserver or DNS/MX records

    ingo
     
    Ingo Linkweiler, Sep 24, 2006
    #1
    1. Advertising

  2. Ingo Linkweiler wrote:

    > b) verify an existing mailserver or DNS/MX records


    "Or"? That's two different things.

    If you don't know already: Even if you test all this, it is still
    possible that

    - the target mail account doesn't exist
    - the sender's IP is filtered by the server so he'll reject
    - the localpart has syntax errors (allowed chars in the localpart
    are up to the server)

    Regards,


    Björn

    --
    BOFH excuse #280:

    Traceroute says that there is a routing problem in the backbone.
    It's not our problem.
     
    Bjoern Schliessmann, Sep 24, 2006
    #2
    1. Advertising

  3. Bjoern Schliessmann schrieb:
    > Ingo Linkweiler wrote:
    >
    >> b) verify an existing mailserver or DNS/MX records

    >
    > "Or"? That's two different things.
    >
    > If you don't know already: Even if you test all this, it is still
    > possible that
    >
    > - the target mail account doesn't exist
    > - the sender's IP is filtered by the server so he'll reject


    Yes, I know this.
    But its still better than not checking it.
    The script will be used as part auf a user registration page to avoid
    dummy-inputs like ""
     
    Ingo Linkweiler, Sep 24, 2006
    #3
  4. In <ef5nop$aoh$>, Ingo Linkweiler wrote:

    > The script will be used as part auf a user registration page to avoid
    > dummy-inputs like ""


    The usual way to cope with this is sending out confirmation mails. No
    need to check if the address is syntactically correct beforehand.

    Ciao,
    Marc 'BlackJack' Rintsch
     
    Marc 'BlackJack' Rintsch, Sep 24, 2006
    #4
  5. > The usual way to cope with this is sending out confirmation mails. No
    > need to check if the address is syntactically correct beforehand.


    yes, I do this allready. But it would be nice to do some checks before
    to avoid wrong user inputs.
     
    Ingo Linkweiler, Sep 24, 2006
    #5
  6. Ingo Linkweiler wrote:

    > yes, I do this allready. But it would be nice to do some checks
    > before to avoid wrong user inputs.


    What do you do if the user inputs a "wrong" address? If you reject
    with an error message, the medium intelligent user will enter
    something like



    as next try, circumventing your test.

    Regards,


    Björn

    --
    BOFH excuse #178:

    short leg on process table
     
    Bjoern Schliessmann, Sep 24, 2006
    #6
  7. Ingo Linkweiler

    Ben Finney Guest

    Bjoern Schliessmann <> writes:

    > Ingo Linkweiler wrote:
    >
    > > yes, I do this allready. But it would be nice to do some checks
    > > before to avoid wrong user inputs.

    >
    > What do you do if the user inputs a "wrong" address? If you reject
    > with an error message, the medium intelligent user will enter
    > something like
    >
    >
    >
    > as next try, circumventing your test.


    I believe Ingo is checking for the case where the user intended to
    enter a valid email address, and made a typing error resulting in a
    trivially invalid one.

    --
    \ "'Did you sleep well?' 'No, I made a couple of mistakes.'" -- |
    `\ Steven Wright |
    _o__) |
    Ben Finney
     
    Ben Finney, Sep 24, 2006
    #7
  8. Ben Finney wrote:

    > I believe Ingo is checking for the case where the user intended to
    > enter a valid email address, and made a typing error resulting in
    > a trivially invalid one.


    Ah. Good intention, but the same applies: Typos in the localpart are
    not detectable. Typos in the domain part could mostly be easily
    corrected by hand, too.

    Regards,


    Björn

    --
    BOFH excuse #297:

    Too many interrupts
     
    Bjoern Schliessmann, Sep 24, 2006
    #8
  9. "Ingo Linkweiler" <> wrote in message
    news:ef5nop$aoh$...
    > Bjoern Schliessmann schrieb:
    > > Ingo Linkweiler wrote:
    > >
    > >> b) verify an existing mailserver or DNS/MX records

    > >
    > > "Or"? That's two different things.
    > >
    > > If you don't know already: Even if you test all this, it is still
    > > possible that
    > >
    > > - the target mail account doesn't exist
    > > - the sender's IP is filtered by the server so he'll reject

    >
    > Yes, I know this.
    > But its still better than not checking it.
    > The script will be used as part auf a user registration page to avoid
    > dummy-inputs like ""


    Why bother, you will loose anyway:

    For those kind of sites demanding registration for trivial usage (i.e. most
    sites do) I use my own domain controlled by myself - the adress is valid for the
    confirmation mail then, after I got what I came for (or after I found out that
    this site was a waste of time, which happens entirely too often), the adress is
    not valid anymore.

    Cuts down the spamvertising a lot!
     
    Frithiof Andreas Jensen, Sep 25, 2006
    #9
  10. On Sun, 24 Sep 2006 13:23:03 +0200, Ingo Linkweiler wrote:

    >> The usual way to cope with this is sending out confirmation mails. No
    >> need to check if the address is syntactically correct beforehand.

    >
    > yes, I do this allready. But it would be nice to do some checks before
    > to avoid wrong user inputs.


    Because you like reinventing the wheel and doing the same work twice?

    By memory, in an thread about the same topic just a few days ago, Fredrik
    Lundh posted a link to Perl's FAQs that suggests a method for "validating"
    email addresses: treat it like a password and ask the user to type it
    twice. That will protect against simple typos and input errors.

    For everything else, send to it and see what happens.


    --
    Steven D'Aprano
     
    Steven D'Aprano, Sep 25, 2006
    #10
  11. Ingo Linkweiler

    Christophe Guest

    Steven D'Aprano a écrit :
    > By memory, in an thread about the same topic just a few days ago, Fredrik
    > Lundh posted a link to Perl's FAQs that suggests a method for "validating"
    > email addresses: treat it like a password and ask the user to type it
    > twice. That will protect against simple typos and input errors.


    I hate that thing. When I see that, I type my email once and copy/paste
    into the second edit box. This is useless AND annoying at the same time.
     
    Christophe, Sep 25, 2006
    #11
  12. Ingo Linkweiler

    Steve Holden Guest

    Christophe wrote:
    > Steven D'Aprano a écrit :
    >
    >>By memory, in an thread about the same topic just a few days ago, Fredrik
    >>Lundh posted a link to Perl's FAQs that suggests a method for "validating"
    >>email addresses: treat it like a password and ask the user to type it
    >>twice. That will protect against simple typos and input errors.

    >
    >
    > I hate that thing. When I see that, I type my email once and copy/paste
    > into the second edit box. This is useless AND annoying at the same time.


    Probably safe to say it's a little less useful when the text field
    contents are visible, but the classic validator for hidden fields.

    It might surprise you to realise that not everyone in the world is a
    touch typist, and for them (since they are often looking at the keyboard
    rather than the screen) it's not an unreasonable validator.

    regards
    Steve
    --
    Steve Holden +44 150 684 7255 +1 800 494 3119
    Holden Web LLC/Ltd http://www.holdenweb.com
    Skype: holdenweb http://holdenweb.blogspot.com
    Recent Ramblings http://del.icio.us/steve.holden
     
    Steve Holden, Sep 25, 2006
    #12
  13. Ingo Linkweiler

    Georg Brandl Guest

    Christophe wrote:
    > Steven D'Aprano a écrit :
    >> By memory, in an thread about the same topic just a few days ago, Fredrik
    >> Lundh posted a link to Perl's FAQs that suggests a method for "validating"
    >> email addresses: treat it like a password and ask the user to type it
    >> twice. That will protect against simple typos and input errors.

    >
    > I hate that thing. When I see that, I type my email once and copy/paste
    > into the second edit box. This is useless AND annoying at the same time.


    It may be for you, but there certainly are users that misspel their
    e-mail address more frequently, just like passwords. And therefore it's a
    nice touch to spare both the original submitter and the owner of the
    misspelled address more work.

    Georg
     
    Georg Brandl, Sep 25, 2006
    #13
  14. Ingo Linkweiler

    Christophe Guest

    Georg Brandl a écrit :
    > Christophe wrote:
    >> Steven D'Aprano a écrit :
    >>> By memory, in an thread about the same topic just a few days ago,
    >>> Fredrik
    >>> Lundh posted a link to Perl's FAQs that suggests a method for
    >>> "validating"
    >>> email addresses: treat it like a password and ask the user to type it
    >>> twice. That will protect against simple typos and input errors.

    >>
    >> I hate that thing. When I see that, I type my email once and
    >> copy/paste into the second edit box. This is useless AND annoying at
    >> the same time.

    >
    > It may be for you, but there certainly are users that misspel their
    > e-mail address more frequently, just like passwords. And therefore it's a
    > nice touch to spare both the original submitter and the owner of the
    > misspelled address more work.


    Which proportion of the people that sometimes misspell their e-mail also
    use cut&paste when faced with "please type your e-mail twice" web pages?
     
    Christophe, Sep 25, 2006
    #14
  15. Ingo Linkweiler

    Christophe Guest

    Steve Holden a écrit :
    > Christophe wrote:
    >> Steven D'Aprano a écrit :
    >>
    >>> By memory, in an thread about the same topic just a few days ago,
    >>> Fredrik
    >>> Lundh posted a link to Perl's FAQs that suggests a method for
    >>> "validating"
    >>> email addresses: treat it like a password and ask the user to type it
    >>> twice. That will protect against simple typos and input errors.

    >>
    >>
    >> I hate that thing. When I see that, I type my email once and
    >> copy/paste into the second edit box. This is useless AND annoying at
    >> the same time.

    >
    > Probably safe to say it's a little less useful when the text field
    > contents are visible, but the classic validator for hidden fields.
    >
    > It might surprise you to realise that not everyone in the world is a
    > touch typist, and for them (since they are often looking at the keyboard
    > rather than the screen) it's not an unreasonable validator.


    Well, if they have a hard time using a keyboard, I've no doubts they
    will love using cut&paste to cut nearly in half the time needed to fill
    out your form :)
     
    Christophe, Sep 25, 2006
    #15
  16. Frithiof Andreas Jensen wrote:

    > For those kind of sites demanding registration for trivial usage (i.e. most
    > sites do) I use my own domain controlled by myself - the adress is valid for the
    > confirmation mail then, after I got what I came for (or after I found out that
    > this site was a waste of time, which happens entirely too often), the adress is
    > not valid anymore.


    and for those that are too lazy for that, there's always mailinator.com
    and friends.

    </F>
     
    Fredrik Lundh, Sep 25, 2006
    #16
  17. Ingo Linkweiler

    Georg Brandl Guest

    Christophe wrote:
    > Georg Brandl a écrit :
    >> Christophe wrote:
    >>> Steven D'Aprano a écrit :
    >>>> By memory, in an thread about the same topic just a few days ago,
    >>>> Fredrik
    >>>> Lundh posted a link to Perl's FAQs that suggests a method for
    >>>> "validating"
    >>>> email addresses: treat it like a password and ask the user to type it
    >>>> twice. That will protect against simple typos and input errors.
    >>>
    >>> I hate that thing. When I see that, I type my email once and
    >>> copy/paste into the second edit box. This is useless AND annoying at
    >>> the same time.

    >>
    >> It may be for you, but there certainly are users that misspel their
    >> e-mail address more frequently, just like passwords. And therefore it's a
    >> nice touch to spare both the original submitter and the owner of the
    >> misspelled address more work.

    >
    > Which proportion of the people that sometimes misspell their e-mail also
    > use cut&paste when faced with "please type your e-mail twice" web pages?


    I don't know. But really, it doesn't matter. The cut-and-paste operation
    (which is done at least partially using the mouse by most such people) needs
    a lot of "eye contact" with the thing cut and pasted, so there's a lot
    more chances to realize that the address is wrong.

    Georg
     
    Georg Brandl, Sep 25, 2006
    #17
  18. On Mon, 25 Sep 2006 16:11:38 +0200, Christophe wrote:

    > Steven D'Aprano a écrit :
    >> By memory, in an thread about the same topic just a few days ago, Fredrik
    >> Lundh posted a link to Perl's FAQs that suggests a method for "validating"
    >> email addresses: treat it like a password and ask the user to type it
    >> twice. That will protect against simple typos and input errors.

    >
    > I hate that thing. When I see that, I type my email once and copy/paste
    > into the second edit box.


    So do I -- even for passwords. (Oooh, I live on the edge... *wink*)


    > This is useless AND annoying at the same time.


    But people like us don't screw up our email address in the first place,
    and if we do, we know how to fix it. Not everybody is like us.



    --
    Steven D'Aprano
     
    Steven D'Aprano, Sep 26, 2006
    #18
  19. Ingo Linkweiler

    Christophe Guest

    Steven D'Aprano a écrit :
    > On Mon, 25 Sep 2006 16:11:38 +0200, Christophe wrote:
    >> This is useless AND annoying at the same time.

    >
    > But people like us don't screw up our email address in the first place,
    > and if we do, we know how to fix it. Not everybody is like us.


    So you say that the better answer is not to teach them to be careful
    when they fill those forms. It's to annoy them and teach them to
    copy&paste mistakes instead!

    Besides, what is so special with electronic forms that we have to go
    through all kind of tricks to make sure the user doesn't make mistakes
    when regular paper forms just assume the user will be careful when he
    fills it? Must be some kind of IQ draining field emited by all the
    computers which only computer experts are immune to :D
     
    Christophe, Sep 26, 2006
    #19
  20. > Besides, what is so special with electronic forms that we have to go
    > through all kind of tricks to make sure the user doesn't make mistakes
    > when regular paper forms just assume the user will be careful when he
    > fills it? Must be some kind of IQ draining field emited by all the
    > computers which only computer experts are immune to :D


    The speciality comes from paper forms being read by humans - or at least
    that used to be the case. And as we still are more clever than your average
    OCR program (and even than the not-so-average ones), that leads to
    comparably good results.

    But a computer that is supposed to process an electronic form - you have to
    make sure to apply proper bondage techniques to make the user obey to your
    command....

    Diez
     
    Diez B. Roggisch, Sep 26, 2006
    #20
    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. Axel
    Replies:
    1
    Views:
    534
    White Wolf
    Sep 15, 2003
  2. active

    Using e-mail to verify new username

    active, Jul 4, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    338
    active
    Jul 4, 2007
  3. Stefan Falk

    Getting E-Mail-Adress of User in a Web Service

    Stefan Falk, Dec 22, 2003, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    113
    Chris S
    Dec 24, 2003
  4. Sam Roberts
    Replies:
    0
    Views:
    227
    Sam Roberts
    Mar 20, 2005
  5. gavino
    Replies:
    2
    Views:
    174
    Ted Zlatanov
    Jul 27, 2006
Loading...

Share This Page