當前位置: 首頁>>代碼示例>>Python>>正文


Python email.MIMEMessage方法代碼示例

本文整理匯總了Python中email.MIMEMessage方法的典型用法代碼示例。如果您正苦於以下問題:Python email.MIMEMessage方法的具體用法?Python email.MIMEMessage怎麽用?Python email.MIMEMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在email的用法示例。


在下文中一共展示了email.MIMEMessage方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_generate

# 需要導入模塊: import email [as 別名]
# 或者: from email 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:IronLanguages,項目名稱:ironpython2,代碼行數:21,代碼來源:test_email.py

示例2: test_rfc2047_Q_invalid_digits

# 需要導入模塊: import email [as 別名]
# 或者: from email 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:IronLanguages,項目名稱:ironpython2,代碼行數:10,代碼來源:test_email.py

示例3: test_type_error

# 需要導入模塊: import email [as 別名]
# 或者: from email import MIMEMessage [as 別名]
def test_type_error(self):
        self.assertRaises(TypeError, MIMEMessage, 'a plain string') 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:4,代碼來源:test_email.py

示例4: test_valid_argument

# 需要導入模塊: import email [as 別名]
# 或者: from email 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:IronLanguages,項目名稱:ironpython2,代碼行數:15,代碼來源:test_email.py

示例5: test_bad_multipart

# 需要導入模塊: import email [as 別名]
# 或者: from email 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:IronLanguages,項目名稱:ironpython2,代碼行數:10,代碼來源:test_email.py

示例6: test_rfc2047_Q_invalid_digits

# 需要導入模塊: import email [as 別名]
# 或者: from email 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:dxwu,項目名稱:BinderFilter,代碼行數:10,代碼來源:test_email.py

示例7: test_valid_argument

# 需要導入模塊: import email [as 別名]
# 或者: from email 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:dxwu,項目名稱:BinderFilter,代碼行數:16,代碼來源:test_email.py

示例8: test_rfc2047_with_whitespace

# 需要導入模塊: import email [as 別名]
# 或者: from email 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:ofermend,項目名稱:medicare-demo,代碼行數:12,代碼來源:test_email.py

示例9: test_valid_argument

# 需要導入模塊: import email [as 別名]
# 或者: from email 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:ofermend,項目名稱:medicare-demo,代碼行數:16,代碼來源:test_email.py


注:本文中的email.MIMEMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。