Jun-26-2024, 07:12 AM
Make your own re expression! State explicitly what you allow, or state explicitly what you disallow. Here I've gone with disallow.
Email format is governed by several RFC documents like RFC 5322. What exactly is disallowed in the email address is not quite clear to me. Exclude all the ugly bits like this:
This, ^, at the beginning in [ ] means NOT, so NOT any of these following symbols. If you want to exclude the letter a, put that in the square brackets too!
Thus e has the format (if no banned stuff)@(if no banned stuff) then the email is good.
I've been trying with openssl s_client to verify the list of emails, but I have not yet succeeded! At the moment, all I can do is send an email and look for "Email not sent", then take that email off the list
If you have a clue about that, please let me know!
But if the email is just for login, it does not actually need to really exist!
Email format is governed by several RFC documents like RFC 5322. What exactly is disallowed in the email address is not quite clear to me. Exclude all the ugly bits like this:
This, ^, at the beginning in [ ] means NOT, so NOT any of these following symbols. If you want to exclude the letter a, put that in the square brackets too!
[^=+!#$%&~ ?,<>;:\/()[\]{}]Put anything you want excluded in the [ ] but after the ^. If the character is a special character in re, you will need to escape it, like ] must be escaped: \] or re will complain.
Thus e has the format (if no banned stuff)@(if no banned stuff) then the email is good.
import re email = input('Enter what you think is a valid email ... ') email1 = '[email protected]' email2 = 'King(Charles)[email protected]' # no match email3 = 'King-[Charles][email protected]' # no match email4 = 'King/Charles/[email protected]' # no match email5 = 'King\Charles\[email protected]' # no match email6 = 'King_Charles_III@royal?.email.com.co.uk' # no match """ Maybe some of the things in e are not officially banned, but banned by me here! As a whole, the email address cannot be more that 254 characters long I read. """ e = re.compile(r'([^=+!#$%&~ ?,<>;:\/()[\]{}*])@([^=+!#$%&~ ?,<>;:\/()[\]{}*]\Z)') if not e.match(email): print(f'This email: {email} contains banned characters, try again ... ')Example:
Output:email = input('Enter what you think is a valid email ... ')
Enter what you think is a valid email ... King*[email protected]
if not e.match(email):
print(f'This email: {email} is the wrong format, try again ... ')
This email: King*[email protected] is the wrong format, try again ...
Verifying the email is a different kettle of fish! I made some Python to send emails to a list of customers for the girlfriend.I've been trying with openssl s_client to verify the list of emails, but I have not yet succeeded! At the moment, all I can do is send an email and look for "Email not sent", then take that email off the list
If you have a clue about that, please let me know!
But if the email is just for login, it does not actually need to really exist!