Python email.MIMEMessage() Examples
The following are 30
code examples of email.MIMEMessage().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
email
, or try the search function
.
Example #1
Source File: test_email.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
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. """)
Example #2
Source File: test_email.py From medicare-demo with Apache License 2.0 | 6 votes |
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. """)
Example #3
Source File: test_email.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
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. """)
Example #4
Source File: test_email.py From datafari with Apache License 2.0 | 6 votes |
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. """)
Example #5
Source File: test_email.py From oss-ftp with MIT License | 6 votes |
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. """)
Example #6
Source File: test_email.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
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. """)
Example #7
Source File: test_email.py From BinderFilter with MIT License | 6 votes |
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. """)
Example #8
Source File: test_email.py From ironpython2 with Apache License 2.0 | 6 votes |
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. """)
Example #9
Source File: test_email.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
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. """)
Example #10
Source File: test_email.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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)
Example #11
Source File: test_email.py From medicare-demo with Apache License 2.0 | 5 votes |
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)
Example #12
Source File: test_email.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_type_error(self): self.assertRaises(TypeError, MIMEMessage, 'a plain string')
Example #13
Source File: test_email.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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)
Example #14
Source File: test_email.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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)
Example #15
Source File: test_email.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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)
Example #16
Source File: test_email.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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)
Example #17
Source File: test_email.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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
Example #18
Source File: test_email.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_type_error(self): self.assertRaises(TypeError, MIMEMessage, 'a plain string')
Example #19
Source File: test_email.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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)
Example #20
Source File: test_email.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_type_error(self): self.assertRaises(TypeError, MIMEMessage, 'a plain string')
Example #21
Source File: test_email.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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
Example #22
Source File: test_email.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_type_error(self): self.assertRaises(TypeError, MIMEMessage, 'a plain string')
Example #23
Source File: test_email.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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)
Example #24
Source File: test_email.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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
Example #25
Source File: test_email.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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)
Example #26
Source File: test_email.py From oss-ftp with MIT License | 5 votes |
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)
Example #27
Source File: test_email.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_type_error(self): self.assertRaises(TypeError, MIMEMessage, 'a plain string')
Example #28
Source File: test_email.py From ironpython2 with Apache License 2.0 | 5 votes |
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)
Example #29
Source File: test_email.py From ironpython2 with Apache License 2.0 | 5 votes |
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)
Example #30
Source File: test_email.py From BinderFilter with MIT License | 5 votes |
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