Checking if email is valid

Chris Angelico rosuav at gmail.com
Wed Nov 1 17:55:27 EDT 2023


On Thu, 2 Nov 2023 at 08:52, Grant Edwards via Python-list
<python-list at python.org> wrote:
>
> 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?

Yeah they will; but that'll depend on the exact server you send to,
whereas if you have a domain part, all you need is some server that
accepts mail for forwarding.

> > (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...
>
> :)

Yyyyyyyyeah I think we can assume SMTP these days :)

ChrisA


More information about the Python-list mailing list