I have never had a need to check email but in my reading over the years, I am 
aware of modules of multiple kinds you can use to do things like parsing dates, 
URL and email addresses and probably many other such things into some kind of 
object and then you can use aspects of the object to do interesting things and 
perhaps change some and then ask for the object to be placed back into some 
other format such as text.

My guess is that a first test of an email address might be to see if a decent 
module of that kind fills out the object to your satisfaction. You can then 
perhaps test parts of the object, rather than everything at once, to see if it 
is obviously invalid. As an example, what does u...@alpha.......com with what 
seems to be lots of meaningless periods, get parsed into?

This may be another approach that reuses what may be well-designed and tested 
shared software.  I wonder if there are also such modules that do quite a bit 
of what is asked which is to reject a large class of badly formed addresses. 
You could, of course, take what survives and run additional screens.

In the end, this is a bit like junkmail where some light-AI algorithms go over 
a corpus of messages that humans have curated as junk or not junk and make some 
statistical decisions that are nonetheless often wrong. In that case, many 
humans nastily declare thinks as SPAM just because they do not want to get such 
messages. If you blasted out email alerts every time a child seems to have been 
kidnapped to everyone in the nation, how long before many such messages would 
become designated as SPAM?

So is there any work where people have taken a decent collection of email 
addresses used in the past that turned out to be syntactically valid or not, 
and trained an algorithm to recognize most of them properly? That trained 
algorithm could be shared and incorporated into your programs either as the 
only method, or one you use in special cases.

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail....@python.org> On 
Behalf Of Mike Dewhirst via Python-list
Sent: Thursday, November 2, 2023 6:31 PM
To: python-list@python.org
Subject: Re: Checking if email is valid

If i wanted an email verifier I would look at open source frameworks and see 
how they do it. Django comes to mind.--(Unsigned mail from my phone)
-------- Original message --------From: Michael Torrie via Python-list 
<python-list@python.org> Date: 3/11/23  07:23  (GMT+10:00) To: 
python-list@python.org Subject: Re: Checking if email is valid On 11/2/23 
00:42, Simon Connah via Python-list wrote:> Basically I'm writing unit tests 
and one of them passess in a string > with an invalid email address. I need to 
be able to check the string > to see if it is a valid email so that the unit 
test passess.If you truly have managed to code an RFC-compliant verifier, I 
commend you.> Valid as in conforms to the standard. Although having looked at 
the> standard that might be more difficult than originally planned.You'll have 
to read the relevant RFCs.  Lots of corner cases!  From whatI can see virtually 
no one on the internet gets it right, judging by thenumber of times I have 
valid email addresses flagged as not valid bypoor algorithms.-- 
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to