本文整理汇总了Python中mail.Mail.disconnect方法的典型用法代码示例。如果您正苦于以下问题:Python Mail.disconnect方法的具体用法?Python Mail.disconnect怎么用?Python Mail.disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mail.Mail
的用法示例。
在下文中一共展示了Mail.disconnect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import disconnect [as 别名]
class Message:
def __init__(self):
self.__LOG_TAG__ = "MESSAGE"
self.__mail = Mail(self.__read_mail_values())
self.__whatsapp = WhatsApp()
def __read_mail_values(self):
"""Read e-mail values in xml configuration file"""
tree = xml.dom.minidom.parse("../config.xml")
config = tree.getElementsByTagName('config')[0]
msg_config = config.getElementsByTagName('msg_config')[0]
l_email = msg_config.getElementsByTagName('email')[0]
l_description = l_email.getAttribute('description')
l_host = l_email.getAttribute('host')
l_port = int(l_email.getAttribute('port'))
l_login = l_email.getAttribute('login')
l_password = l_email.getAttribute('password')
l_sender = l_email.getAttribute('sender')
l_target = l_email.getAttribute('target') #for tests. later can be any user's email
l_complete = True
log.info(self.__LOG_TAG__, "Infos of e-mail read [%s]" %l_sender)
return l_description, l_host, l_port, l_login, l_password, l_sender, l_target, l_complete
def is_connected_mail(self):
"""Check if email server is connected"""
return self.__mail.is_connected()
def connect_mail(self):
"""Connect to email server."""
self.__mail.connect();
def test_connection_mail(self):
"""Try to reconnect to the server if it is not connected."""
self.__mail.test_connection()
def disconnect_mail(self):
"""Disconnecd from email server"""
self.__mail.disconnect()
def send_mail(self, p_target, p_subject="[no_subject]", p_msg="Hello!"):
"""send one or more emails
target: str, list or tuple
"""
self.__mail.send(p_target, p_subject, p_msg)