Soroush Ghodsi
Soroush Ghodsi

Reputation: 380

Python - Validate Whether Email Exists

I'm trying some emails using the Python validate_email library, it seems to have three functions:

1. is_valid = validate_email('[email protected]')

2. is_valid = validate_email('[email protected]',check_mx=True)

3. is_valid = validate_email('[email protected]',verify=True)

I would really appreciate an explanation as to exactly what each one does. The first one always gives me True and the third always gives None. Thank you in advance!

P.S. If there are any other Python libraries for doing this I would love to know about those too.

Upvotes: 2

Views: 5567

Answers (1)

sameera sy
sameera sy

Reputation: 1718

validate_email is a package in python that check if an email is valid and really exists.

check_mx=True

is used to check whether the host has a smtp server, What I mean is if there is a mailing server associated with example.com. Every company may or may not have a mailing server, if so then you may have for ex. [email protected], else they will use premailing platforms like gmail or yahoo. check_mx will return true if there is a mailing server for somecompany.com regardless of whether there is a individual email address present for that mailing server.

verify=True

checks whether there is an email address called '[email protected]', returns true only when both conditions satisfy that is check_mx condition and the individual email address condition. hope this helps.

Upvotes: 1

Related Questions