#NEWLINE# def connect( self ) : #NEWLINE# #INDENT# self . log . info ( 'Connecting to IMAP server {0!r} port {1}' . format ( self . mail_server , self . mail_port ) ) #NEWLINE# if self . mail_disable_ssl : #NEWLINE# #INDENT# mail_class = _IMAP4 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# mail_class = _IMAP4_SSL #NEWLINE# #UNINDENT# mailbox = mail_class ( self . mail_server , self . mail_port , timeout = self . mail_connection_timeout ) #NEWLINE# self . log . info ( 'Logging in to IMAP server {0!r} port {1}' . format ( self . mail_server , self . mail_port ) ) #NEWLINE# mailbox . login ( self . mail_user , self . mail_password ) #NEWLINE# try : #NEWLINE# #INDENT# ( status , msgs ) = mailbox . select ( self . mail_box , readonly = False ) #NEWLINE# if ( status != 'OK' ) : #NEWLINE# #INDENT# for msg in msgs : #NEWLINE# #INDENT# raise imaplib . IMAP4 . abort ( msg ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# mailbox . logout ( ) #NEWLINE# raise #NEWLINE# #UNINDENT# self . log . info ( 'Logged in to IMAP server {0!r} port {1}' . format ( self . mail_server , self . mail_port ) ) #NEWLINE# return mailbox