首页 > 其他 > 详细

imaplib.IMAP4_SSL属性代码示例

时间:2020-10-16 20:31:38      阅读:103      评论:0      收藏:0      [点我收藏+]

您也可以进一步了解该属性所在模块imaplib的用法示例。

示例1: open_connection

# 需要导入模块: 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 

 

imaplib.IMAP4_SSL属性代码示例

原文:https://www.cnblogs.com/sunbeibei/p/13828063.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!