On 29/12/2020 09:27, Richard Damon wrote:
On 12/28/20 3:08 PM, Mats Wichmann wrote:
On 12/28/20 10:46 AM, Marco Sulla wrote:
On Mon, 28 Dec 2020 at 17:37, Bischoop <bisch...@vimart.net> wrote:
...

but probably what you really want is a regular expression.

<shudders>

because...


Will add that Yes, you should always validate your inputs, but No, the
presence of an @ sign in a text string is not sufficient to know it's
a valid email address. Unfortunately validating that is hard.


Validating that it meets the SYNTAX of an email address isn't THAT hard,
but there are a number of edge cases to worry about.

Validating that it is a working email address (presumably after
verifying that it has a proper syntax) is much harder, and basically
requires trying to send to the address, and to really confirm that it is
good requires them to do something actively with a message you send
them. And then nothing says the address will continue to be valid.


(am assuming the in/is question has been answered)


Looking at my email server log, I see messages addressed to "fd0d8f761...@danceswithmice.info" - which have been rejected.

That spurious-address features an "@". It is a perfectly-formed email address. The domain-name is correct - and can be quickly verified as in-existence.

However the account-name is a total fabrication. (is someone trying to put a 'hex' on me?)


Accordingly, the advice that the only way to check if an email address is 'correct', is to see if it is accepted by the receiving-server. However, you can't (shouldn't be able to!) pierce that veil, to be able to prove/see for yourself!

That is why many subscription-systems send an initial email message and ask the receiver to confirm receipt by 'clicking on the link provided'!


Per previous RegEx discussions 'here': there are plenty of examples/attempts floating around the Internet. Absolutely none of which comes with a guarantee!

To quote the famous con-man/men/women: if you believe any such stories, come and see me about buying into the Brooklyn Bridge/some agricultural (marsh) land/the next best thing...

For many years, many of the RegEx-s circulating were so precise that they only recognised the original TLDs such as .com and .org. For years after .info was introduced, sites would tell me that my email address was 'illegal'. Leaving me to ask: do I really exist?, am I but part of some imaginary universe? (no comments about my Hobbit-feet, please!)


After such disparagement it is worth remembering that there are checks and there are checks! It depends upon the purpose of the check, or the level-of-detail/accuracy desired!

When accepting user-data it *is* worth (even "necessary") performing a 'sanity-check'. Per @Chris, if the user doesn't enter two 'words' separated by an @-sign, and the second 'word' doesn't include at least one dot/period/stop, then it seems quite probable that our user has made a typo! This is why some sites require an email address to be entered twice. (but copy-paste anyone?)


Going much further than a typo-reducing/sanity-check is, per @Richard, considerably harder - and ultimately cannot guarantee an address. Thus, indulges in a sub-field of cyber-alchemy!
--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to