def user_email_in_whitelist(email, domains):
    """
    Check to see if a user's email address is within one of
    the whitelisted domains. Only returns True if an explicit
    match has been found. This matching is case-insensitive.

    NOTE: This routine is a critical security function.
    """
    allowed = False
    lower_domains = [d.strip().lower() for d in domains if d.strip()]
    if email and lower_domains:
        domain = email.split('@', 1)[1]
        allowed = domain.lower() in lower_domains
    return allowed