'Signs in to the mail account with the given username and password,
raises a MailLoginError otherwise.'

def login(self, username, password, **kwargs):

    self.logout()
    self._secure = kwargs.get('secure', self._secure)
    self._imap4 = ((self._secure and IMAP4_SSL) or IMAP4)(self._host, self._port)
    try:
        (status, response) = self._imap4.login(username, password)
    except:
        raise MailLoginError
    if (status != 'OK'):
        raise MailLoginError(response)
