How to use the pyisemail.validators.DNSValidator function in pyIsEmail

To help you get started, we’ve selected a few pyIsEmail examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github michaelherold / pyIsEmail / tests / validators / test_dns_validator.py View on Github external
def setUp(self):
        self.validator = DNSValidator()
        self.is_valid = self.validator.is_valid
github michaelherold / pyIsEmail / pyisemail / __init__.py View on Github external
def is_email(address, check_dns=False, diagnose=False):
    """Validate an email address.

    Keyword arguments:
    address   --- the email address as a string
    check_dns --- flag for whether to check the DNS status of the domain
    diagnose  --- flag for whether to return True/False or a Diagnosis

    """

    threshold = BaseDiagnosis.CATEGORIES["THRESHOLD"]
    d = ParserValidator().is_email(address, True)
    if check_dns is True and d < BaseDiagnosis.CATEGORIES["DNSWARN"]:
        threshold = BaseDiagnosis.CATEGORIES["VALID"]
        d = max(d, DNSValidator().is_valid(address.split("@")[1], True))

    return d if diagnose else d < threshold