On 01Nov2023 14:08, Grant Edwards <grant.b.edwa...@gmail.com> wrote:
On 2023-11-01, Simon Connah via Python-list <python-list@python.org> wrote:
I'm building a simple project using smtplib and have a
question. I've been doing unit testing but I'm not sure how to check
if an email message is valid.
[...]
Could someone push me in the right direction please? I just want to
find out if a string is a valid email address.
I confess that I punt "syntactically valid" to email.utils.getaddresses:
https://docs.python.org/3/library/email.utils.html#email.utils.getaddresses
"Deliverable"? I'm prepared to just send to it and hope not to get a
bounce; delivery of email is, after all, asynchronous. (Even if it were
going direct to the primary MX, I still hand it to the local mail system
to deal with.)
"A real person or entity"? A lot of systems do the round trip thing:
here's a special unique and opaue URL,please visit it to confirm receipt
of this email (implying email is 'real"). You see this a lot when
signing up for things. And for plenty of things I generate a random
throw away address at mailinator.com (looking at you, every "catch up"
free online TV streaming service who still wants me to log in).
Cheers,
Cameron Simpson <c...@cskk.id.au>
--
https://mail.python.org/mailman/listinfo/python-list