当前位置: 首页>>代码示例>>Python>>正文


Python Message.attach方法代码示例

本文整理汇总了Python中mailman.email.message.Message.attach方法的典型用法代码示例。如果您正苦于以下问题:Python Message.attach方法的具体用法?Python Message.attach怎么用?Python Message.attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mailman.email.message.Message的用法示例。


在下文中一共展示了Message.attach方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_non_ascii_message

# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import attach [as 别名]
 def test_non_ascii_message(self):
     msg = Message()
     msg['From'] = '[email protected]'
     msg['To'] = '[email protected]'
     msg['Content-Type'] = 'multipart/mixed'
     msg.attach(MIMEText('message with non-ascii chars: \xc3\xa9',
                         'plain', 'utf-8'))
     mbox = digest_mbox(self._mlist)
     mbox_path = os.path.join(self._mlist.data_path, 'digest.mmdf')
     mbox.add(msg.as_string())
     self._digestq.enqueue(
         msg,
         listname=self._mlist.fqdn_listname,
         digest_path=mbox_path,
         volume=1, digest_number=1)
     # Use any error logs as the error message if the test fails.
     error_log = LogFileMark('mailman.error')
     self._runner.run()
     # The runner will send the file to the shunt queue on exception.
     self.assertEqual(len(self._shuntq.files), 0, error_log.read())
     # There are two messages in the virgin queue: the digest as plain-text
     # and as multipart.
     messages = get_queue_messages('virgin')
     self.assertEqual(len(messages), 2)
     self.assertEqual(
         sorted(item.msg.get_content_type() for item in messages),
         ['multipart/mixed', 'text/plain'])
     for item in messages:
         self.assertEqual(item.msg['subject'],
                          'Test Digest, Vol 1, Issue 1')
开发者ID:adam-iris,项目名称:mailman,代码行数:32,代码来源:test_digest.py

示例2: test_non_ascii_message

# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import attach [as 别名]
 def test_non_ascii_message(self):
     msg = Message()
     msg['From'] = '[email protected]'
     msg['To'] = '[email protected]'
     msg['Content-Type'] = 'multipart/mixed'
     msg.attach(MIMEText('message with non-ascii chars: \xc3\xa9',
                         'plain', 'utf-8'))
     mbox = digest_mbox(self._mlist)
     mbox.add(msg.as_string())
     # Use any error logs as the error message if the test fails.
     error_log = LogFileMark('mailman.error')
     make_digest_messages(self._mlist, msg)
     # The runner will send the file to the shunt queue on exception.
     self.assertEqual(len(self._shuntq.files), 0, error_log.read())
     self._check_virgin_queue()
开发者ID:aditigupta96,项目名称:mailman3,代码行数:17,代码来源:test_digest.py

示例3: test_non_ascii_message

# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import attach [as 别名]
 def test_non_ascii_message(self):
     # Subscribe some users receiving digests.
     anne = subscribe(self._mlist, 'Anne')
     anne.preferences.delivery_mode = DeliveryMode.mime_digests
     bart = subscribe(self._mlist, 'Bart')
     bart.preferences.delivery_mode = DeliveryMode.plaintext_digests
     msg = Message()
     msg['From'] = '[email protected]'
     msg['To'] = '[email protected]'
     msg['Content-Type'] = 'multipart/mixed'
     msg.attach(MIMEText('message with non-ascii chars: \xc3\xa9',
                         'plain', 'utf-8'))
     mbox = digest_mbox(self._mlist)
     mbox.add(msg.as_string())
     # Use any error logs as the error message if the test fails.
     error_log = LogFileMark('mailman.error')
     make_digest_messages(self._mlist, msg)
     # The runner will send the file to the shunt queue on exception.
     self.assertEqual(len(self._shuntq.files), 0, error_log.read())
     self._check_virgin_queue()
开发者ID:P-EB,项目名称:mailman3-core,代码行数:22,代码来源:test_digest.py


注:本文中的mailman.email.message.Message.attach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。