'Perform APOP authentication.
Override the default lookup scheme to allow virtual domains.
@type user: L{bytes}
@param user: The name of the user attempting to log in.
@type digest: L{bytes}
@param digest: The challenge response.
@rtype: L{Deferred} which successfully results in 3-L{tuple} of
(L{IMailbox <pop3.IMailbox>}, L{IMailbox <pop3.IMailbox>}
provider, no-argument callable)
@return: A deferred which fires when authentication is complete.
If successful, it returns an L{IMailbox <pop3.IMailbox>} interface,
a mailbox and a logout function. If authentication fails, the
deferred fails with an L{UnauthorizedLogin
<twisted.cred.error.UnauthorizedLogin>} error.'

def authenticateUserAPOP(self, user, digest):

    (user, domain) = self.lookupDomain(user)
    try:
        portal = self.service.lookupPortal(domain)
    except KeyError:
        return defer.fail(UnauthorizedLogin())
    else:
        return portal.login(pop3.APOPCredentials(self.magic, user, digest), None, pop3.IMailbox)
