本文整理汇总了Python中mailshake.EmailMessage.as_string方法的典型用法代码示例。如果您正苦于以下问题:Python EmailMessage.as_string方法的具体用法?Python EmailMessage.as_string怎么用?Python EmailMessage.as_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mailshake.EmailMessage
的用法示例。
在下文中一共展示了EmailMessage.as_string方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dont_base64_encode
# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import as_string [as 别名]
def test_dont_base64_encode():
"""Shouldn't use Base64 encoding at all.
"""
email = EmailMessage('Subject', 'UTF-8 encoded body', '[email protected]',
'[email protected]',
headers={'From': '[email protected]'})
assert 'Content-Transfer-Encoding: base64' not in email.as_string()
示例2: test_message_header_overrides
# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import as_string [as 别名]
def test_message_header_overrides():
"""Specifying dates or message-ids in the extra headers overrides the
default values.
"""
headers = {'date': 'Fri, 09 Nov 2001 01:08:47 -0000', 'Message-ID': 'foo'}
email = EmailMessage('Subject', 'Content', '[email protected]',
'[email protected]', headers=headers)
assert email.as_string() == 'Content-Type: text/plain; charset="utf-8"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\nSubject: Subject\nFrom: [email protected]\nTo: [email protected]\ndate: Fri, 09 Nov 2001 01:08:47 -0000\nMessage-ID: foo\n\nContent'
示例3: test_7bit_no_quoted_printable
# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import as_string [as 别名]
def test_7bit_no_quoted_printable():
"""Shouldn't use quoted printable, should detect it can represent content
with 7 bit data.
"""
email = EmailMessage('Subject', 'Body with only ASCII characters.',
'[email protected]', '[email protected]',
headers={'From': '[email protected]'})
msg = email.as_string()
assert 'Content-Transfer-Encoding: quoted-printable' not in msg
assert 'Content-Transfer-Encoding: 7bit' in msg
示例4: test_8bit_no_quoted_printable
# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import as_string [as 别名]
def test_8bit_no_quoted_printable():
"""Shouldn't use quoted printable, should detect it can represent content
with 8 bit data.
"""
email = EmailMessage('Subject', 'Body with latin characters: àáä.',
'[email protected]', '[email protected]',
headers={'From': '[email protected]'})
msg = email.as_string()
assert 'Content-Transfer-Encoding: quoted-printable' not in msg
assert 'Content-Transfer-Encoding: 8bit' in msg
email = EmailMessage('Subject',
u'Body with non latin characters: А Б В Г Д Е Ж Ѕ З И І К Л М Н О П.',
'[email protected]', '[email protected]',
headers={'From': '[email protected]'})
msg = email.as_string()
assert 'Content-Transfer-Encoding: quoted-printable' not in msg
assert 'Content-Transfer-Encoding: 8bit' in msg
示例5: test_dont_mangle_from_in_body
# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import as_string [as 别名]
def test_dont_mangle_from_in_body():
"""Make sure that EmailMessage doesn't mangle 'From' in message body."""
email = EmailMessage('Subject', 'From the future', '[email protected]',
'[email protected]', headers={'From': '[email protected]'})
assert '>From the future' not in email.as_string()