您也可以进一步了解该属性所在模块imaplib
的用法示例。
# 需要导入模块: import imaplib [as 别名] # 或者: from imaplib import IMAP4_SSL [as 别名] def open_connection(): """Opens the connection to the email service by use of the stored credentials""" # TODO: find a more sensible and secure approach or at least recommend # securing the credential file and add handling in the event of being # unable to read it. # Read the config file config = ConfigParser.ConfigParser() config.read([os.path.abspath(os.path.join(‘config‘, ‘settings.ini‘))]) # Connect to the server hostname = config.get(‘server‘, ‘imap-hostname‘) logger.debug(‘Connecting to ‘ + hostname) connection = imaplib.IMAP4_SSL(hostname, 993) # Login to our account username = config.get(‘account‘, ‘username‘) password = config.get(‘account‘, ‘password‘) logger.debug(‘Logging in as ‘ + username) connection.login(username, password) return connection
原文:https://www.cnblogs.com/sunbeibei/p/13828063.html