本文整理匯總了Python中email.message.set_from方法的典型用法代碼示例。如果您正苦於以下問題:Python message.set_from方法的具體用法?Python message.set_from怎麽用?Python message.set_from使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類email.message
的用法示例。
在下文中一共展示了message.set_from方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_message
# 需要導入模塊: from email import message [as 別名]
# 或者: from email.message import set_from [as 別名]
def get_message(self, key):
"""Return a Message representation or raise a KeyError."""
start, stop = self._lookup(key)
self._file.seek(start)
from_line = self._file.readline().replace(os.linesep, '')
string = self._file.read(stop - self._file.tell())
msg = self._message_factory(string.replace(os.linesep, '\n'))
msg.set_from(from_line[5:])
return msg
示例2: __init__
# 需要導入模塊: from email import message [as 別名]
# 或者: from email.message import set_from [as 別名]
def __init__(self, message=None):
"""Initialize an mboxMMDFMessage instance."""
self.set_from('MAILER-DAEMON', True)
if isinstance(message, email.message.Message):
unixfrom = message.get_unixfrom()
if unixfrom is not None and unixfrom.startswith('From '):
self.set_from(unixfrom[5:])
Message.__init__(self, message)
示例3: set_from
# 需要導入模塊: from email import message [as 別名]
# 或者: from email.message import set_from [as 別名]
def set_from(self, from_, time_=None):
"""Set "From " line, formatting and appending time_ if specified."""
if time_ is not None:
if time_ is True:
time_ = time.gmtime()
from_ += ' ' + time.asctime(time_)
self._from = from_
示例4: get_message
# 需要導入模塊: from email import message [as 別名]
# 或者: from email.message import set_from [as 別名]
def get_message(self, key):
"""Return a Message representation or raise a KeyError."""
start, stop = self._lookup(key)
self._file.seek(start)
from_line = self._file.readline().replace(linesep, b'')
string = self._file.read(stop - self._file.tell())
msg = self._message_factory(string.replace(linesep, b'\n'))
msg.set_from(from_line[5:].decode('ascii'))
return msg