Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding an optional check to remove disposable emails #56

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

geoffreybauduin
Copy link

Adding an optional check to prevent validating disposable emails

@@ -96,6 +97,17 @@ class ServerError(Exception):
MX_CHECK_CACHE = {}


def is_disposable(email, debug=False):
"""Indicate whether the email is known as being a disposable email or not"""
for domain in _disposable:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no no! do it better
do it like this:

email_domain = email.rsplit('@',1)[1]
if email_domain in _disposable:
    # logger stuff
    return True
return False

@geoffreybauduin
Copy link
Author

@wtayyeb thanks for your advices, I also took the liberty to change the list of disposable domains to a set, since the lookup is faster in a set than in a list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants