def _open_pop3_mailbox(event, host, port, username, password, protocol, debug): cev = event.data['connection'] = { 'live': False, 'error': [False, _('Nothing is wrong')] } try: # FIXME: Nothing actually adds gmail or gmail-full to the protocol # yet, so we're stuck in recent mode only for now. if (username.lower().split('@')[-1] in GMAIL_TLDS or 'gmail' in protocol): if 'gmail-full' not in protocol: username = '******' % username return pop3.MailpileMailbox(host, port=port, user=username, password=password, use_ssl=('ssl' in protocol), debug=debug) except AccessError: cev['error'] = ['auth', _('Invalid username or password')] except (IOError, OSError): cev['error'] = ['network', _('A network error occurred')] event.data['traceback'] = traceback.format_exc() return None
def _open_pop3_mailbox(session, event, host, port, username, password, auth_type, protocol, debug, throw=False): cev = event.data['connection'] = { 'live': False, 'error': [False, _('Nothing is wrong')] } try: # FIXME: Nothing actually adds gmail or gmail-full to the protocol # yet, so we're stuck in recent mode only for now. if (username.lower().split('@')[-1] in GMAIL_TLDS or 'gmail' in protocol): if 'gmail-full' not in protocol: username = '******' % username if 'ssl' in protocol: need = [ConnBroker.OUTGOING_POP3S] else: need = [ConnBroker.OUTGOING_POP3] with ConnBroker.context(need=need): return pop3.MailpileMailbox(host, port=port, user=username, password=password, auth_type=auth_type, use_ssl=('ssl' in protocol), session=session, debug=debug) except AccessError: cev['error'] = [ 'auth', _('Invalid username or password'), username, sha1b64(password) ] except (ssl.CertificateError, ssl.SSLError): cev['error'] = [ 'tls', _('Failed to make a secure TLS connection'), '%s:%s' % (host, port) ] except (IOError, OSError): cev['error'] = ['network', _('A network error occurred')] event.data['traceback'] = traceback.format_exc() if throw: raise throw(cev['error'][1]) return None
def _open_pop3_mailbox(event, host, port, username, password, protocol, debug): cev = event.data['connection'] = { 'live': False, 'error': [False, _('Nothing is wrong')] } try: return pop3.MailpileMailbox(host, port=port, user=username, password=password, use_ssl=protocol, debug=debug) except AccessError: cev['error'] = ['auth', _('Invalid username or password')] except (IOError, OSError): cev['error'] = ['network', _('A network error occurred')] return None
def open_mailbox(self, mbx_id, mfn): my_cfg = self.my_config if mfn.startswith('src:') and FormatMbxId(mbx_id) in my_cfg.mailbox: cev = self.event.data['connection'] = { 'live': False, 'error': [False, _('Nothing is wrong')] } try: debug = ('pop3' in self.session.config.sys.debug) and 99 or 0 return pop3.MailpileMailbox(my_cfg.host, port=my_cfg.port, user=my_cfg.username, password=my_cfg.password, use_ssl='ssl' in my_cfg.protocol, debug=debug) except AccessError: cev['error'] = ['auth', _('Invalid username or password')] except (IOError, OSError): cev['error'] = ['network', _('A network error occurred')] return None