Checking if email is valid

Grant Edwards grant.b.edwards at gmail.com
Wed Nov 1 17:50:43 EDT 2023


On 2023-11-01, Chris Angelico via Python-list <python-list at python.org> wrote:
> On Thu, 2 Nov 2023 at 08:09, Grant Edwards via Python-list
><python-list at python.org> wrote:

>> Make sure it has an '@' in it.  Possibly require at least one '.'
>> after the '@'.
>
> No guarantee that there'll be a dot after the at.

Ah, I forgot about defaulting to a local domain if one is
omitted. Will MTAs do that these days?

> (Technically there's no guarantee of an at sign either, but email
> addresses without at signs are local-only, so in many contexts, you
> can assume there needs to be an at.)
>
> So the regex to match all valid email addresses that aren't
> local-only is... drumroll please...
>
> r"@"

Unless you want to support UUCP or X400 addresses...

:)






More information about the Python-list mailing list