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


Python MIMEMessage.MIMEMessage方法代码示例

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


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

示例1: test_generate

# 需要导入模块: from email import MIMEMessage [as 别名]
# 或者: from email.MIMEMessage import MIMEMessage [as 别名]
def test_generate(self):
        # First craft the message to be encapsulated
        m = Message()
        m['Subject'] = 'An enclosed message'
        m.set_payload('Here is the body of the message.\n')
        r = MIMEMessage(m)
        r['Subject'] = 'The enclosing message'
        s = StringIO()
        g = Generator(s)
        g.flatten(r)
        self.assertEqual(s.getvalue(), """\
Content-Type: message/rfc822
MIME-Version: 1.0
Subject: The enclosing message

Subject: An enclosed message

Here is the body of the message.
""") 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:21,代码来源:test_email.py

示例2: test_rfc2047_with_whitespace

# 需要导入模块: from email import MIMEMessage [as 别名]
# 或者: from email.MIMEMessage import MIMEMessage [as 别名]
def test_rfc2047_with_whitespace(self):
        s = 'Sm =?ISO-8859-1?B?9g==?= rg =?ISO-8859-1?B?5Q==?= sbord'
        dh = decode_header(s)
        self.assertEqual(dh, [('Sm', None), ('\xf6', 'iso-8859-1'),
                              ('rg', None), ('\xe5', 'iso-8859-1'),
                              ('sbord', None)])



# Test the MIMEMessage class 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:12,代码来源:test_email.py

示例3: test_type_error

# 需要导入模块: from email import MIMEMessage [as 别名]
# 或者: from email.MIMEMessage import MIMEMessage [as 别名]
def test_type_error(self):
        self.assertRaises(TypeError, MIMEMessage, 'a plain string') 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:4,代码来源:test_email.py

示例4: test_valid_argument

# 需要导入模块: from email import MIMEMessage [as 别名]
# 或者: from email.MIMEMessage import MIMEMessage [as 别名]
def test_valid_argument(self):
        eq = self.assertEqual
        unless = self.failUnless
        subject = 'A sub-message'
        m = Message()
        m['Subject'] = subject
        r = MIMEMessage(m)
        eq(r.get_content_type(), 'message/rfc822')
        payload = r.get_payload()
        unless(isinstance(payload, list))
        eq(len(payload), 1)
        subpart = payload[0]
        unless(subpart is m)
        eq(subpart['subject'], subject) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:16,代码来源:test_email.py

示例5: test_bad_multipart

# 需要导入模块: from email import MIMEMessage [as 别名]
# 或者: from email.MIMEMessage import MIMEMessage [as 别名]
def test_bad_multipart(self):
        eq = self.assertEqual
        msg1 = Message()
        msg1['Subject'] = 'subpart 1'
        msg2 = Message()
        msg2['Subject'] = 'subpart 2'
        r = MIMEMessage(msg1)
        self.assertRaises(Errors.MultipartConversionError, r.attach, msg2) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:10,代码来源:test_email.py

示例6: test_rfc2047_Q_invalid_digits

# 需要导入模块: from email import MIMEMessage [as 别名]
# 或者: from email.MIMEMessage import MIMEMessage [as 别名]
def test_rfc2047_Q_invalid_digits(self):
        # issue 10004.
        s = '=?iso-8659-1?Q?andr=e9=zz?='
        self.assertEqual(decode_header(s),
                        [(b'andr\xe9=zz', 'iso-8659-1')])


# Test the MIMEMessage class 
开发者ID:adde88,项目名称:hostapd-mana,代码行数:10,代码来源:test_email.py

示例7: test_valid_argument

# 需要导入模块: from email import MIMEMessage [as 别名]
# 或者: from email.MIMEMessage import MIMEMessage [as 别名]
def test_valid_argument(self):
        eq = self.assertEqual
        subject = 'A sub-message'
        m = Message()
        m['Subject'] = subject
        r = MIMEMessage(m)
        eq(r.get_content_type(), 'message/rfc822')
        payload = r.get_payload()
        self.assertIsInstance(payload, list)
        eq(len(payload), 1)
        subpart = payload[0]
        self.assertIs(subpart, m)
        eq(subpart['subject'], subject) 
开发者ID:adde88,项目名称:hostapd-mana,代码行数:15,代码来源:test_email.py

示例8: test_rfc2047_Q_invalid_digits

# 需要导入模块: from email import MIMEMessage [as 别名]
# 或者: from email.MIMEMessage import MIMEMessage [as 别名]
def test_rfc2047_Q_invalid_digits(self):
        # issue 10004.
        s = '=?iso-8859-1?Q?andr=e9=zz?='
        self.assertEqual(decode_header(s),
                        [(b'andr\xe9=zz', 'iso-8859-1')])


# Test the MIMEMessage class 
开发者ID:oilshell,项目名称:oil,代码行数:10,代码来源:test_email.py

示例9: test_valid_argument

# 需要导入模块: from email import MIMEMessage [as 别名]
# 或者: from email.MIMEMessage import MIMEMessage [as 别名]
def test_valid_argument(self):
        eq = self.assertEqual
        unless = self.assertTrue
        subject = 'A sub-message'
        m = Message()
        m['Subject'] = subject
        r = MIMEMessage(m)
        eq(r.get_content_type(), 'message/rfc822')
        payload = r.get_payload()
        unless(isinstance(payload, list))
        eq(len(payload), 1)
        subpart = payload[0]
        unless(subpart is m)
        eq(subpart['subject'], subject) 
开发者ID:gittor,项目名称:ndk-python,代码行数:16,代码来源:test_email.py


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