Checking if email is valid

Simon Connah simon.n.connah at protonmail.com
Wed Nov 1 07:35:01 EDT 2023


OK. I've been doing some reading and that you should avoid regex to check email addresses. 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.

Thank you!

------- Original Message -------
On Wednesday, 1 November 2023 at 10:09, Simon Connah <simon.n.connah at protonmail.com> wrote:


> 

> 

> Hi,
> 

> 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. 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.
> 

> Thank you.
> 

> Simon.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
URL: <https://mail.python.org/pipermail/python-list/attachments/20231101/5d3cdd0b/attachment.sig>


More information about the Python-list mailing list