Exemple #1
0
def validate_email():
    """
        :param email: string the address to be validates
        :return: response: EmailValidatorResponse success status and message
        Read more at
        https://github.com/mariodmtrv/RobustMail/wiki#check-an-email
    """
    email = request.get_json()["email"].strip()
    if not EmailValidator.is_syntax_valid(email):
        response = EmailValidatorResponse(False, "Address syntax invalid")
    elif not EmailValidator.is_mx_valid(email):
        response = EmailValidatorResponse(False, "Address domain not found")
    else:
        response = EmailValidatorResponse(True, "Syntax and domain accepted")
        # address existence validation was excluded because of performance and reliability issues
    return response.to_JSON()
Exemple #2
0
def validate_email():
    """
        :param email: string the address to be validates
        :return: response: EmailValidatorResponse success status and message
        Read more at
        https://github.com/mariodmtrv/RobustMail/wiki#check-an-email
    """
    email = request.get_json()["email"].strip()
    if not EmailValidator.is_syntax_valid(email):
        response = EmailValidatorResponse(False, "Address syntax invalid")
    elif not EmailValidator.is_mx_valid(email):
        response = EmailValidatorResponse(False, "Address domain not found")
    else:
        response = EmailValidatorResponse(True, "Syntax and domain accepted")
        # address existence validation was excluded because of performance and reliability issues
    return response.to_JSON()