user7551211
user7551211

Reputation: 707

How to Check if an Email Exist in Python?

I use Python 3 and I want to check if an email address exists before I send an email.

I've tried pip's validate_email package and it doesn't work at all. It returns true for every string that includes '@' in the middle without symbols. Maybe there's another pip package that does work (I saw packages like validate-email-address, email-validator, py3-validate-email, and email-validator)? Or some code to check that with SMTP?

Upvotes: 4

Views: 1936

Answers (1)

phd
phd

Reputation: 94417

By default, validate_email doesn't really validate much. You have to enable DNS validation and SMTP validation:

validate_email(email, check_mx=True, verify=True, smtp_timeout=60)

Upvotes: 4

Related Questions