Checking if email is valid

dn PythonList at DancesWithMice.info
Wed Nov 1 16:35:18 EDT 2023


On 02/11/2023 00.35, Simon Connah via Python-list wrote:
> OK. I've been doing some reading and that you should avoid regex to check email addresses. 

This operation used to be a BIG THING back in the days of 'everyone' 
building PHP web-sites. When there were only a handful of TLDs 
(top-level domain names, eg the country-codes* such as .nz and .uk plus 
the generics such as .com and .net. Accordingly, one could hold the 
entire list for convenience of checking. However when IANA (the outfit 
responsible for the Root Zone Database and especially ICANN realised 
that there was money to be made, they allowed more and more TLDs. 
Keeping-up became a rat-race!

Indeed, I've held another .info domain for twenty years, and used to 
suffer for my 'bleeding edge' daring - quite recently someone (who 
should remain name-less, and a few other less-es) sent me an email 
telling me how to log-in, but their log-in process wouldn't accept the 
'illegal' address. Ummmmmmmmm...

All together now: "a little bit of knowledge is a dangerous thing"!


So what I was thinking was something like this:
> 
> if type(email_recipient) != email.message.Message:
> 
> I just don't know why that particular line isn't working.

Will need more context. What is the objective? What is the 
source/pre-processing of these data-items. (etc)



* Left-out .au, (a less important geo-TLD) to wind-up @Chris...

-- 
Regards,
=dn


More information about the Python-list mailing list