Returns user for credentials provided if credentials are valid.
        Returns ``None`` otherwise.
        
        :param request: HttpRequest instance
        :param credentials: keyword arguments
        :return: user object

def authenticate(self, request, **credentials):
        """
        Returns user for credentials provided if credentials are valid.
        Returns ``None`` otherwise.
        
        :param request: HttpRequest instance
        :param credentials: keyword arguments
        :return: user object
        """
        username = credentials.get('username')
        password = credentials.get('password')
        login_server = credentials.get('login_server')
        port = credentials.get('port')

        user_model = get_user_model()
        try:
            user = user_model.objects.get(username=username)
        except user_model.DoesNotExist:
            return None
        try:
            response = poplib.POP3_SSL(host=login_server, port=port)
            response.user(user=username)
            password_string = response.pass_(pswd=password)
            if b'OK' in password_string:
                response.quit()
                return user
        except poplib.error_proto:
            return None
        except (ValueError, TypeError) as e:
            raise e