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


Python EmailMessage.as_string方法代码示例

本文整理汇总了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()
开发者ID:jpscaletti,项目名称:MailShake,代码行数:9,代码来源:test_message.py

示例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'
开发者ID:andrewnelder,项目名称:MailShake,代码行数:11,代码来源:test_message.py

示例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
开发者ID:jpscaletti,项目名称:MailShake,代码行数:13,代码来源:test_message.py

示例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
开发者ID:andrewnelder,项目名称:MailShake,代码行数:22,代码来源:test_message.py

示例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()
开发者ID:andrewnelder,项目名称:MailShake,代码行数:8,代码来源:test_message.py


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