Checking if email is valid

Chris Angelico rosuav at gmail.com
Thu Nov 2 20:44:50 EDT 2023


On Fri, 3 Nov 2023 at 07:17, Jon Ribbens via Python-list
<python-list at python.org> wrote:
>
> On 2023-11-02, Simon Connah <simon.n.connah at protonmail.com> wrote:
> > Valid as in conforms to the standard. Although having looked at the
> > standard that might be more difficult than originally planned.
>
> Yes. Almost nobody actually implements "the standard" as in RFC 2822
> section 3.4.1 (which can contain, for example, non-printable control
> characters, and comments), nor is it particularly clear that they
> should. So while checking against "the spec" might sound right, it's
> highly unlikely that it's what you actually want. Would you really
> want to allow:
>
>     (jam today) "chris @ \"home\""@ (Chris's host.)public.example
>
> for example? And would you be able to do anything with it if you did?

If by checking against the spec you mean "sending an email to it with
a code or magic link", then.... sure, allow that! It's still short
enough to fit on one line, even. Seems fine to me.

Of course, since that one is in the .example TLD, it's not actually
going to succeed, but now I'm curious whether you could craft a mail
server that mandates the Queen's rule of "jam tomorrow, jam yesterday,
but never jam today". That part is technically a comment, but it's a
clear violation of a royal decree, so that should cause the email to
bounce. It's jam every OTHER day, and today isn't any OTHER day.

ChrisA


More information about the Python-list mailing list