Re: Checking if email is valid
On Fri, 3 Nov 2023 at 12:21, AVI GROSS via Python-list wrote: > 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? > What do you mean by "obviously invalid"? Have you read the RFC? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
RE: Checking if email is valid
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 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 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
Re: Checking if email is valid
On Fri, 3 Nov 2023 at 07:17, Jon Ribbens via Python-list wrote: > > On 2023-11-02, Simon Connah wrote: > > Valid as in conforms to the standard. Although having looked at the > > standard that might be more difficult than originally planned. > > Yes. Almost nobody actually implements "the standard" as in RFC 2822 > section 3.4.1 (which can contain, for example, non-printable control > characters, and comments), nor is it particularly clear that they > should. So while checking against "the spec" might sound right, it's > highly unlikely that it's what you actually want. Would you really > want to allow: > > (jam today) "chris @ \"home\""@ (Chris's host.)public.example > > for example? And would you be able to do anything with it if you did? If by checking against the spec you mean "sending an email to it with a code or magic link", then sure, allow that! It's still short enough to fit on one line, even. Seems fine to me. Of course, since that one is in the .example TLD, it's not actually going to succeed, but now I'm curious whether you could craft a mail server that mandates the Queen's rule of "jam tomorrow, jam yesterday, but never jam today". That part is technically a comment, but it's a clear violation of a royal decree, so that should cause the email to bounce. It's jam every OTHER day, and today isn't any OTHER day. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
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 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
Re: pip/pip3 confusion and keeping up to date
On 11/2/23 04:58, Chris Green via Python-list wrote: I have a couple of systems which used to have python2 as well as python3 but as Ubuntu and Debian verions have moved on they have finally eliminated all dependencies on python2. So they now have only python3 and there is no python executable in PATH. FWIW, for this you install the little stub package python-is-python3. Especially if you want to keep a python2 installation around - "python" will still be python3 in this case. So, going on from this, how do I do the equivalent of "apt update; apt upgrade" for my globally installed pip packages Odds are you don't want to. The internet is full of surprises about dependency problems when stuff is blindly updated; the set of Python packages in the apt repositories is carefully curated to avoid these problems - and this is part of the reason why sometimes certain such packages are irritatingly down-rev. -- https://mail.python.org/mailman/listinfo/python-list
Re: pip/pip3 confusion and keeping up to date
On 2023-11-02, Chris Green wrote: > Jon Ribbens wrote: >> On 2023-11-02, Dieter Maurer wrote: >> > Chris Green wrote at 2023-11-2 10:58 +: >> >> ... >> >>So, going on from this, how do I do the equivalent of "apt update; apt >> >>upgrade" for my globally installed pip packages? >> > >> > `pip list -o` will tell you for which packages there are upgrades >> > available. >> > `pip install -U ...` will upgrade packages. >> > >> > Be careful, though. >> > With `apt`, you usually have (`apt`) sources representing a consistent >> > package universe. Someone tests that package upgrades in this >> > universe do not break other packages (in this universe). >> > Because of this, upgrading poses low risk. >> > >> > `PyPI` does not guarantes consistency. A new package version >> > may be incompatible to a previous one -- and with other >> > package you have installed. >> > >> > I do not think that you would want to auto-upgrade all installed >> > packages. >> >> Indeed. What you're describing is a very unfortunate failing of pip. >> 'Upgrade' doesn't even follow requirements when you tell it what to >> upgrade - e.g. if you do "pip install foo" and foo requires "bar<2" >> so you end up with: >> >>PackageVersion >>-- - >>foo1.0.0 >>bar1.2.0 >> >> and then a new version 1.3.0 of bar comes out and you do >> "pip install -U foo", pip will not upgrade bar even though it could >> and should, because foo is already at the latest version so pip won't >> even look at its dependencies. >> >> Indeed there is no way of knowing that you should upgrade bar without >> manually following all the dependency graphs. ("pip list -o" will tell >> you there's a newer version, but that isn't the same - e.g. if the new >> version of bar was 2.0.0 then "pip list -o" will list it, but you should >> not upgrade to it.) >> >> You can do "pip install -I foo", which will pointlessly reinstall foo >> and then presumably upgrade bar as well, thus probably getting to the >> right result via a rather roundabout route, but I'm not sure if that >> does indeed work properly and if it is a reliable and recommended way >> of doing things. > > It is a bit of a minefield isn't it. I try to minimise my use of > packages installed using pip for this very reason. Maybe the safest > route would simply be to uninstall everything and then re-install it. That is literally what I do quite often - completely erase the virtual env and then re-create it from scratch - because it seems to be the only / easiest way to upgrade the packages to the latest versions consistent with given dependencies. -- https://mail.python.org/mailman/listinfo/python-list
Re: pip/pip3 confusion and keeping up to date
On 2023-11-02, Chris Green wrote: > Jon Ribbens wrote: >> On 2023-11-02, Chris Green wrote: >> > I have a couple of systems which used to have python2 as well as >> > python3 but as Ubuntu and Debian verions have moved on they have >> > finally eliminated all dependencies on python2. >> > >> > So they now have only python3 and there is no python executable in >> > PATH. >> > >> > There's still both /usr/bin/pip and /usr/bin/pip3 but they're >> > identical so presuably I can now simply use pip and it will be a >> > python3 pip. >> > >> > >> > So, going on from this, how do I do the equivalent of "apt update; apt >> > upgrade" for my globally installed pip packages? >> >> I'm not sure what that question has to do with everything that preceded >> it, but you don't want to install python packages globally using pip. >> Either install them with 'apt', or install them in a virtual environment. > > Why in a virtual environment? When I install a package whether from > apt or from pip I want everyone/everything on my system to be able to > use it. Because pip barely plays well by itself, let alone with other package managers at the same time. > I do only install a few things using pip. Are they not available in your system's package manager? I guess you might get away with "sudo -H pip install -U foo" for a couple of things, if they don't have many dependencies. -- https://mail.python.org/mailman/listinfo/python-list
Re: pip/pip3 confusion and keeping up to date
Jon Ribbens wrote: > On 2023-11-02, Chris Green wrote: > > I have a couple of systems which used to have python2 as well as > > python3 but as Ubuntu and Debian verions have moved on they have > > finally eliminated all dependencies on python2. > > > > So they now have only python3 and there is no python executable in > > PATH. > > > > There's still both /usr/bin/pip and /usr/bin/pip3 but they're > > identical so presuably I can now simply use pip and it will be a > > python3 pip. > > > > > > So, going on from this, how do I do the equivalent of "apt update; apt > > upgrade" for my globally installed pip packages? > > I'm not sure what that question has to do with everything that preceded > it, but you don't want to install python packages globally using pip. > Either install them with 'apt', or install them in a virtual environment. Why in a virtual environment? When I install a package whether from apt or from pip I want everyone/everything on my system to be able to use it. I do only install a few things using pip. -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list
Re: pip/pip3 confusion and keeping up to date
Jon Ribbens wrote: > On 2023-11-02, Dieter Maurer wrote: > > Chris Green wrote at 2023-11-2 10:58 +: > >> ... > >>So, going on from this, how do I do the equivalent of "apt update; apt > >>upgrade" for my globally installed pip packages? > > > > `pip list -o` will tell you for which packages there are upgrades > > available. > > `pip install -U ...` will upgrade packages. > > > > Be careful, though. > > With `apt`, you usually have (`apt`) sources representing a consistent > > package universe. Someone tests that package upgrades in this > > universe do not break other packages (in this universe). > > Because of this, upgrading poses low risk. > > > > `PyPI` does not guarantes consistency. A new package version > > may be incompatible to a previous one -- and with other > > package you have installed. > > > > I do not think that you would want to auto-upgrade all installed > > packages. > > Indeed. What you're describing is a very unfortunate failing of pip. > 'Upgrade' doesn't even follow requirements when you tell it what to > upgrade - e.g. if you do "pip install foo" and foo requires "bar<2" > so you end up with: > >PackageVersion >-- - >foo1.0.0 >bar1.2.0 > > and then a new version 1.3.0 of bar comes out and you do > "pip install -U foo", pip will not upgrade bar even though it could > and should, because foo is already at the latest version so pip won't > even look at its dependencies. > > Indeed there is no way of knowing that you should upgrade bar without > manually following all the dependency graphs. ("pip list -o" will tell > you there's a newer version, but that isn't the same - e.g. if the new > version of bar was 2.0.0 then "pip list -o" will list it, but you should > not upgrade to it.) > > You can do "pip install -I foo", which will pointlessly reinstall foo > and then presumably upgrade bar as well, thus probably getting to the > right result via a rather roundabout route, but I'm not sure if that > does indeed work properly and if it is a reliable and recommended way > of doing things. It is a bit of a minefield isn't it. I try to minimise my use of packages installed using pip for this very reason. Maybe the safest route would simply be to uninstall everything and then re-install it. · -- https://mail.python.org/mailman/listinfo/python-list
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 what I can see virtually no one on the internet gets it right, judging by the number of times I have valid email addresses flagged as not valid by poor algorithms. -- https://mail.python.org/mailman/listinfo/python-list
Re: pip/pip3 confusion and keeping up to date
On 2023-11-02, Chris Green wrote: > I have a couple of systems which used to have python2 as well as > python3 but as Ubuntu and Debian verions have moved on they have > finally eliminated all dependencies on python2. > > So they now have only python3 and there is no python executable in > PATH. > > There's still both /usr/bin/pip and /usr/bin/pip3 but they're > identical so presuably I can now simply use pip and it will be a > python3 pip. > > > So, going on from this, how do I do the equivalent of "apt update; apt > upgrade" for my globally installed pip packages? I'm not sure what that question has to do with everything that preceded it, but you don't want to install python packages globally using pip. Either install them with 'apt', or install them in a virtual environment. -- https://mail.python.org/mailman/listinfo/python-list
Re: pip/pip3 confusion and keeping up to date
On 2023-11-02, Dieter Maurer wrote: > Chris Green wrote at 2023-11-2 10:58 +: >> ... >>So, going on from this, how do I do the equivalent of "apt update; apt >>upgrade" for my globally installed pip packages? > > `pip list -o` will tell you for which packages there are upgrades > available. > `pip install -U ...` will upgrade packages. > > Be careful, though. > With `apt`, you usually have (`apt`) sources representing a consistent > package universe. Someone tests that package upgrades in this > universe do not break other packages (in this universe). > Because of this, upgrading poses low risk. > > `PyPI` does not guarantes consistency. A new package version > may be incompatible to a previous one -- and with other > package you have installed. > > I do not think that you would want to auto-upgrade all installed > packages. Indeed. What you're describing is a very unfortunate failing of pip. 'Upgrade' doesn't even follow requirements when you tell it what to upgrade - e.g. if you do "pip install foo" and foo requires "bar<2" so you end up with: PackageVersion -- - foo1.0.0 bar1.2.0 and then a new version 1.3.0 of bar comes out and you do "pip install -U foo", pip will not upgrade bar even though it could and should, because foo is already at the latest version so pip won't even look at its dependencies. Indeed there is no way of knowing that you should upgrade bar without manually following all the dependency graphs. ("pip list -o" will tell you there's a newer version, but that isn't the same - e.g. if the new version of bar was 2.0.0 then "pip list -o" will list it, but you should not upgrade to it.) You can do "pip install -I foo", which will pointlessly reinstall foo and then presumably upgrade bar as well, thus probably getting to the right result via a rather roundabout route, but I'm not sure if that does indeed work properly and if it is a reliable and recommended way of doing things. -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
On 2023-11-02, Simon Connah wrote: > Valid as in conforms to the standard. Although having looked at the > standard that might be more difficult than originally planned. Yes. Almost nobody actually implements "the standard" as in RFC 2822 section 3.4.1 (which can contain, for example, non-printable control characters, and comments), nor is it particularly clear that they should. So while checking against "the spec" might sound right, it's highly unlikely that it's what you actually want. Would you really want to allow: (jam today) "chris @ \"home\""@ (Chris's host.)public.example for example? And would you be able to do anything with it if you did? -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
On 2023-11-02 00:18, AVI GROSS via Python-list wrote: Yes, it would be nice if there was a syntax for sending a test message sort of like an ACK that is not delivered to the recipient but merely results in some status being sent back such as DELIVERABLE or NO SUCH USER or even MAILBOX FULL. It used to do that. The facility was very quickly turned off. I note earlier iterations of email had addressed like mach1!mach2!mach3!ihnp4!mach5!mach6!user or even mach1!mach2!user@mach3 and I remember tools that analyzed what other machines various machines claimed to have a direct connection to and tried to figure out a connection from your source to destination, perhaps a shorter one or maybe a less expensive one. Hence machines like ihnp4 and various universities that were densely connected to others got lots of traffic. In that scenario, validity had another meaning. Yep. It's called UUCP. It still exists. You can even do UUCP over TCP/IP. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Errors
Hello, I would like to develop Mobile Applications using the Kivy Python Framework but I am having difficulty and these are the errors I am finding " C:\WINDOWS\system32>python3 --version Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases." after installing Python 3.9 I also had another error is " WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/kivy-deps-gstreamer-dev/" how can I go about these errors? I am running windows 10 Best Regards *Owner Zigocut Technologies * *+256774306868/701067528* -- https://mail.python.org/mailman/listinfo/python-list
Re: pip/pip3 confusion and keeping up to date
Chris Green wrote at 2023-11-2 10:58 +: > ... >So, going on from this, how do I do the equivalent of "apt update; apt >upgrade" for my globally installed pip packages? `pip list -o` will tell you for which packages there are upgrades available. `pip install -U ...` will upgrade packages. Be careful, though. With `apt`, you usually have (`apt`) sources representing a consistent package universe. Someone tests that package upgrades in this universe do not break other packages (in this universe). Because of this, upgrading poses low risk. `PyPI` does not guarantes consistency. A new package version may be incompatible to a previous one -- and with other package you have installed. I do not think that you would want to auto-upgrade all installed packages. -- https://mail.python.org/mailman/listinfo/python-list
RE: Checking if email is valid
Yes, Chris, many things can be used for lesser purposes. Perhaps this could be like when people automate guessing passwords and one defense is to stop accepting after N bad guesses till some external method resets things. -Original Message- From: Python-list On Behalf Of Chris Angelico via Python-list Sent: Thursday, November 2, 2023 2:05 AM To: python-list@python.org Subject: Re: Checking if email is valid On Thu, 2 Nov 2023 at 15:20, AVI GROSS via Python-list wrote: > > Yes, it would be nice if there was a syntax for sending a test message sort > of like an ACK that is not delivered to the recipient but merely results in > some status being sent back such as DELIVERABLE or NO SUCH USER or even > MAILBOX FULL. > Yes, it would! Spammers would be able to use this syntax to figure out exactly which addresses actually have real people connected to it. It would save them so much trouble! Brilliant idea. ChrisA -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
> Please re-read. > Discussion is about "closeness". > Thus, what you might expect from email servers and Admins, NOT what you > should do. That part should be quite evident by now! > My apologies for making a mistake. Simon. signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
On 2023-11-02 02:04, Chris Angelico via Python-list wrote: On Thu, 2 Nov 2023 at 15:20, AVI GROSS via Python-list wrote: Yes, it would be nice if there was a syntax for sending a test message sort of like an ACK that is not delivered to the recipient but merely results in some status being sent back such as DELIVERABLE or NO SUCH USER or even MAILBOX FULL. Yes, it would! Spammers would be able to use this syntax to figure out exactly which addresses actually have real people connected to it. It would save them so much trouble! Brilliant idea. Which is exactly why we stopped doing it. In fact, mailing software may even have a control to turn it back on but definitely it doesn't reply to the request as delivered. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
pip/pip3 confusion and keeping up to date
I have a couple of systems which used to have python2 as well as python3 but as Ubuntu and Debian verions have moved on they have finally eliminated all dependencies on python2. So they now have only python3 and there is no python executable in PATH. There's still both /usr/bin/pip and /usr/bin/pip3 but they're identical so presuably I can now simply use pip and it will be a python3 pip. So, going on from this, how do I do the equivalent of "apt update; apt upgrade" for my globally installed pip packages? -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
On 2023-11-02, dn wrote: > On 02/11/2023 19.46, Simon Connah via Python-list wrote: >> [...] >> My goal is to make a simple mailing list platform. I guess I could >> just send email to an address and if it bounces then I can remove it >> from the database. Thing is I'm not sure how close to a real email >> address an email has to be in order to be bounced. If it was >> completely wrong it might just swallowed up. > > Exactly! > > Build a complementary script which inspects the returned/bounced > messages, and removes those addresses. > > Given that the list of addresses is built from people signing-up in the > first place, one has to presume that people know their own addresses and > can type - there's no real defence against 'stupid'*. It's not as if you > are making-up addresses yourself (in many jurisdictions it is illegal > without opt-in). Isn't opt-in usually to the effect of "send a message with the subject SUBSCRIBE to listname-reque...@mailinglist.domain.tld " ? Then the trick becomes filtering out the spam; but the "is the email valid" check is somewhat done as a matter of processing that inbound subscribe message. -- |_|O|_| |_|_|O| Github: https://github.com/dpurgert |O|O|O| PGP: DDAB 23FB 19FA 7D85 1CC1 E067 6D65 70E5 4CE7 2860 -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
Chris Angelico writes: On Thu, 2 Nov 2023 at 15:20, AVI GROSS via Python-list wrote: > Yes, it would be nice if there was a syntax for sending a test > message sort of like an ACK that is not delivered to the recipient > but merely results in some status being sent back such as > DELIVERABLE or NO SUCH USER or even MAILBOX FULL. Yes, it would! Spammers would be able to use this syntax to figure out exactly which addresses actually have real people connected to it. It would save them so much trouble! Brilliant idea. That sounds like the SMTP "VRFY" command. And spammers _did_ abuse it in exactly this manner. And so pretty much every mail server in the world disabled VRFY sometime in the 90s. - Alan -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
On 2023-11-02, D'Arcy Cain wrote: > On 2023-11-01 17:17, Chris Angelico via Python-list wrote: >> On Thu, 2 Nov 2023 at 08:09, Grant Edwards via Python-list >> wrote: >>> Make sure it has an '@' in it. Possibly require at least one '.' >>> after the '@'. >> >> No guarantee that there'll be a dot after the at. (Technically there's >> no guarantee of an at sign either, but email addresses without at >> signs are local-only, so in many contexts, you can assume there needs >> to be an at.) > > druid!darcy - doesn't work any more but not because it is syntactically > incorrect. > > Remember the good old days when we were able to test if an address > existed without sending? That was before the black hats discovered the > Internet. I remember the good old days when we were able to send email. -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
On 02/11/2023 20.28, Simon Connah wrote: I'm not sure that would be practical. As I'm setting up a mailing list server I don't know if someone in the future is going to need to use one of those aliases and testing manually would be tedious. Please re-read. Discussion is about "closeness". Thus, what you might expect from email servers and Admins, NOT what you should do. That part should be quite evident by now! -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
> Agreed. > > However, with names that are frequently misspelled or which are > commonly-spelled slightly differently, the 'trick' is to anticipate > problems and set up aliases which forward messages to the correct address*. > > eg Kelvin -> Kevlin > > Niel, Neal, Neale (etc) -> Neil > > > (in the same way that GoodLookingGuy@mydomain -> me, > > or (more likely) MailAdmin -> me) > > > > * however, this can end-up perpetuating the mistake, rather than > correcting... > > -- > Regards, > =dn I'm not sure that would be practical. As I'm setting up a mailing list server I don't know if someone in the future is going to need to use one of those aliases and testing manually would be tedious. Simon. signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
Thursday, November 02, 2023 at 6:46, Simon Connah via Python-list wrote: Re: Checking if email is valid (at least in part) >My goal is to make a simple mailing list platform. I guess I could just send >email to an address and if it bounces then I can remove it from the database. That function is "built in" with many email clients, I use a modified version to move probably dead addresses to a "bounced" folder, from there I can build a Dlist with one click and test again later, even later I add these addresss to a larger Dlist to filter for mail from known bad/dead addresses -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
On 02/11/2023 19.56, Chris Angelico via Python-list wrote: On Thu, 2 Nov 2023 at 17:47, Simon Connah wrote: My goal is to make a simple mailing list platform. I guess I could just send email to an address and if it bounces then I can remove it from the database. Thing is I'm not sure how close to a real email address an email has to be in order to be bounced. If it was completely wrong it might just swallowed up. Every address is completely separate. There is no "closeness". Just send email to an address. Agreed. However, with names that are frequently misspelled or which are commonly-spelled slightly differently, the 'trick' is to anticipate problems and set up aliases which forward messages to the correct address*. eg Kelvin -> Kevlin Niel, Neal, Neale (etc) -> Neil (in the same way that GoodLookingGuy@mydomain -> me, or (more likely) MailAdmin -> me) * however, this can end-up perpetuating the mistake, rather than correcting... -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
> > > See https://www.linuxjournal.com/article/9585?page=0,0 > That looks painful to maintain! signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
On 02/11/2023 19.46, Simon Connah via Python-list wrote: On Thu, 2 Nov 2023 at 05:21, Simon Connah via Python-list python-list@python.org wrote: Could someone push me in the right direction please? I just want to find out if a string is a valid email address. There is only one way to know that a string is a valid email address, and that's to send an email to it. What is your goal though? For example, if you're trying to autolink email addresses in text, you don't really care whether it's valid, only that it looks like an address. My goal is to make a simple mailing list platform. I guess I could just send email to an address and if it bounces then I can remove it from the database. Thing is I'm not sure how close to a real email address an email has to be in order to be bounced. If it was completely wrong it might just swallowed up. Exactly! Build a complementary script which inspects the returned/bounced messages, and removes those addresses. Given that the list of addresses is built from people signing-up in the first place, one has to presume that people know their own addresses and can type - there's no real defence against 'stupid'*. It's not as if you are making-up addresses yourself (in many jurisdictions it is illegal without opt-in). An email address: account@domain, has to be accurate in two ways: 1 the domain - otherwise the DNS (Domain Name System) won't be able to locate the destination email server 2 the account - otherwise the email server won't know to which mail-box the message should be delivered. The (1) is why there was some suggestion of using MX records (but may as well just send the message). The problem with (2) is that some servers will 'bounce' a message, but others will let it die silently (not wanting to add to email-spam by sending stuff 'back' if the message was spam in the first place!) The exception to (2) is a "catch-all" address, which accepts every message not addressed to a (legal) mail-box. These are sometimes used to deal with messages addressed to a staff-member who has left (for example). However, are somewhat problematic because they pick-up tons of garbage (eg earlier today I received a message to 456...@domain.tld. This is not, and never has been, a mail-box on the domain; but would drop into a catch-all mail-box. It would be an unusual MailAdmin inspecting a catch-all address, who would return a mis-addressed email to its source. If the message was addressed to s...@domain.tld, I'd be more likely to assume it was for you, and forward it to you (in the expectation that you'd fix the problem with the sender...). However, ... There are some large businesses doing what you've outlined. They have not solved this problem - and not through lack of trying! * as fast as you make something idiot-proof, the world will show you an 'improved' class of idiot! -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
On Thu, 2 Nov 2023 at 17:47, Cameron Simpson via Python-list wrote: > > On 02Nov2023 17:04, Chris Angelico wrote: > >On Thu, 2 Nov 2023 at 15:20, AVI GROSS via Python-list > > wrote: > >> Yes, it would be nice if there was a syntax for sending a test > >> message sort > >> of like an ACK that is not delivered to the recipient but merely results in > >> some status being sent back such as DELIVERABLE or NO SUCH USER or even > >> MAILBOX FULL. > > > >Yes, it would! Spammers would be able to use this syntax to figure out > >exactly which addresses actually have real people connected to it. It > >would save them so much trouble! Brilliant idea. > > Hmm. IIRC... > > https://datatracker.ietf.org/doc/html/rfc2821#section-4.1.1.6 > > I think a lot of mail receivers don't honour this one, for exactly the > reasons above. Yeah, and it also won't tell you if the mailbox is full, or unattended, or if the email would be rejected or discarded for any other reason. Which means it's not even all that useful if it IS implemented. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
On Thu, 2 Nov 2023 at 17:47, Simon Connah wrote: > > My goal is to make a simple mailing list platform. I guess I could just send > email to an address and if it bounces then I can remove it from the database. > Thing is I'm not sure how close to a real email address an email has to be in > order to be bounced. If it was completely wrong it might just swallowed up. > Every address is completely separate. There is no "closeness". Just send email to an address. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
> > On 2023-11-01, Chris Angelico ros...@gmail.com wrote: > > > On Thu, 2 Nov 2023 at 05:21, Simon Connah via Python-list > > python-list@python.org wrote: > > > > > Could someone push me in the right direction please? I just want to > > > find out if a string is a valid email address. > > > > There is only one way to know that a string is a valid email address, > > and that's to send an email to it. > > > > What is your goal though? For example, if you're trying to autolink > > email addresses in text, you don't really care whether it's valid, > > only that it looks like an address. > > > There's often value in even only partially-effective checks though. > With an email address you can easily check to see if it has an "@", > and if the stuff after the "@" is a syntactically valid domain name. > You can also go a bit further and check to see if the domain has an > MX record, and if it doesn't then it is extremely unlikely that the > address is valid. > -- > https://mail.python.org/mailman/listinfo/python-list Apparently UTF-8 characters are allowed in email addresses now. That is going to lead to a whole new level of pain for determining if an email address is correct. Simon. signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
> > > On Thu, 2 Nov 2023 at 05:21, Simon Connah via Python-list > python-list@python.org wrote: > > > Could someone push me in the right direction please? I just want to find > > out if a string is a valid email address. > > > There is only one way to know that a string is a valid email address, > and that's to send an email to it. > > What is your goal though? For example, if you're trying to autolink > email addresses in text, you don't really care whether it's valid, > only that it looks like an address. > My goal is to make a simple mailing list platform. I guess I could just send email to an address and if it bounces then I can remove it from the database. Thing is I'm not sure how close to a real email address an email has to be in order to be bounced. If it was completely wrong it might just swallowed up. Simon. signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
On 02Nov2023 17:04, Chris Angelico wrote: On Thu, 2 Nov 2023 at 15:20, AVI GROSS via Python-list wrote: Yes, it would be nice if there was a syntax for sending a test message sort of like an ACK that is not delivered to the recipient but merely results in some status being sent back such as DELIVERABLE or NO SUCH USER or even MAILBOX FULL. Yes, it would! Spammers would be able to use this syntax to figure out exactly which addresses actually have real people connected to it. It would save them so much trouble! Brilliant idea. Hmm. IIRC... https://datatracker.ietf.org/doc/html/rfc2821#section-4.1.1.6 I think a lot of mail receivers don't honour this one, for exactly the reasons above. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
> > 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. > > > Send an e-mail using it? If the right person gets the e-mail, then > it's valid? > > > Using regex sounds like a bad idea to me and the other options I > > found required paying for third party services. > > > > Could someone push me in the right direction please? I just want to > > find out if a string is a valid email address. > OK. It is going to take me some time to get round to every reply here so please bear with me. 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. > > You'll have to define "valid". Valid syntactically according to > ? Will be accepted by an SMTP server somewhere? Corresponds to > > a real person? > > Make sure it has an '@' in it. Possibly require at least one '.' > after the '@'. > > Trying to do anything more than that is just wasting your time and > annoying the mule. > Valid as in conforms to the standard. Although having looked at the standard that might be more difficult than originally planned. Simon. signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list
Re: Checking if email is valid
On Thu, 2 Nov 2023 at 15:20, AVI GROSS via Python-list wrote: > > Yes, it would be nice if there was a syntax for sending a test message sort > of like an ACK that is not delivered to the recipient but merely results in > some status being sent back such as DELIVERABLE or NO SUCH USER or even > MAILBOX FULL. > Yes, it would! Spammers would be able to use this syntax to figure out exactly which addresses actually have real people connected to it. It would save them so much trouble! Brilliant idea. ChrisA -- https://mail.python.org/mailman/listinfo/python-list