def open_connection(verbose=False):
# Read the config file
config = configparser.ConfigParser()
config.read([os.path.expanduser('~/.pymotw')])
# Connect to the server
hostname = config.get('server', 'hostname')
if verbose:
print('Connecting to', hostname)
connection = imaplib.IMAP4_SSL(hostname)
# Login to our account
username = config.get('account', 'username')
password = config.get('account', 'password')
if verbose:
print('Logging in as', username)
connection.login(username, password)
return connection
评论列表
文章目录