(imapsets, logger=None, assertok=None)
return imap
Login to the imap server.
Login to the imap server.
Login to the imap server .
def login_imap(imapsets, logger=None, assertok=None):
    """Login to the imap server."""
    if not isinstance(imapsets, ImapSettings):
        raise TypeError("imapsets is not a ImapSettings")

    max_retry = 10
    retry_time = 0.60   # seconds
    for retry in range(1, max_retry + 1):
        try:
            imap = IsbgImap4(imapsets.host, imapsets.port, imapsets.nossl,
                             assertok)
            break   # ok, exit from loop
        except socket.error as exc:
            if logger:
                logger.warning(__(
                    ("Error in IMAP connection: {} ... retry {} of {}"
                     ).format(exc, retry, max_retry)))
            if retry >= max_retry:
                raise Exception(exc)
            else:
                time.sleep(retry_time)
    if logger:
        logger.debug(__("Server capabilities: {}".format(
            imap.capability()[1])))
    if imapsets.nossl and logger:
        logger.warning("WARNING: Using insecure IMAP connection: without SSL.")
    # Authenticate (only simple supported)
    imap.login(imapsets.user, imapsets.passwd)
    return imap
def login_imap ( imapsets , logger = None , assertok = None ) : if not isinstance ( imapsets , ImapSettings ) : raise TypeError ( "imapsets is not a ImapSettings" ) max_retry = 10 retry_time = 0.60 # seconds for retry in range ( 1 , max_retry + 1 ) : try : imap = IsbgImap4 ( imapsets . host , imapsets . port , imapsets . nossl , assertok ) break # ok, exit from loop except socket . error as exc : if logger : logger . warning ( __ ( ( "Error in IMAP connection: {} ... retry {} of {}" ) . format ( exc , retry , max_retry ) ) ) if retry >= max_retry : raise Exception ( exc ) else : time . sleep ( retry_time ) if logger : logger . debug ( __ ( "Server capabilities: {}" . format ( imap . capability ( ) [ 1 ] ) ) ) if imapsets . nossl and logger : logger . warning ( "WARNING: Using insecure IMAP connection: without SSL." ) # Authenticate (only simple supported) imap . login ( imapsets . user , imapsets . passwd ) return imap