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


Python EmailMessage.render方法代码示例

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


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

示例1: test_multiple_message_call

# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import render [as 别名]
def test_multiple_message_call():
    """Make sure that headers are not changed when calling
    `EmailMessage.render()` again.
    """
    email = EmailMessage('Subject', 'Content', '[email protected]',
                         '[email protected]',
                         headers={'From': '[email protected]'})
    message = email.render()
    assert message['From'] == '[email protected]'
    message = email.render()
    assert message['From'] == '[email protected]'
开发者ID:jpscaletti,项目名称:MailShake,代码行数:13,代码来源:test_message.py

示例2: test_safe_mime_multipart

# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import render [as 别名]
def test_safe_mime_multipart():
    """Make sure headers can be set with a different encoding than utf-8 in
    SafeMIMEMultipart as well
    """
    subject = 'Message from Firstname Sürname'
    from_email = '[email protected]'
    to = '"Sürname, Firstname" <[email protected]>'
    text_content = 'This is an important message.'
    html_content = '<p>This is an <strong>important</strong> message.</p>'
    headers = {"Date": "Fri, 09 Nov 2001 01:08:47 -0000", "Message-ID": "foo"}

    email = EmailMessage(subject, text_content, from_email, to,
                         html_content=html_content, headers=headers)
    email.encoding = 'iso-8859-1'
    email.render()
开发者ID:jpscaletti,项目名称:MailShake,代码行数:17,代码来源:test_message.py

示例3: test_unicode_address_header

# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import render [as 别名]
def test_unicode_address_header():
    """When a to/from/cc header contains unicode,
    make sure the email addresses are parsed correctly (especially with
    regards to commas).
    """
    email = EmailMessage('Subject', 'Content', '[email protected]',
                         ['"Firstname Sürname" <[email protected]>',
                          '[email protected]'])
    message = email.render()
    assert message['To'] == '=?utf-8?q?Firstname_S=C3=BCrname?= <[email protected]>, [email protected]'

    email = EmailMessage('Subject', 'Content', '[email protected]',
                         ['[email protected]',
                          '"Sürname, Firstname" <[email protected]>'])
    message = email.render()
    assert message['To'] == '[email protected], =?utf-8?q?S=C3=BCrname=2C_Firstname?= <[email protected]>'
开发者ID:jpscaletti,项目名称:MailShake,代码行数:18,代码来源:test_message.py

示例4: test_space_continuation

# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import render [as 别名]
def test_space_continuation():
    """Test for space continuation character in long (ascii) subject headers.
    """
    email = EmailMessage('Long subject lines that get wrapped should use a space continuation character to get expected behaviour in Outlook and Thunderbird',
                         'Content', '[email protected]', '[email protected]')
    message = email.render()

    assert message['Subject'] == 'Long subject lines that get wrapped should use a space continuation\n character to get expected behaviour in Outlook and Thunderbird'
开发者ID:alfredo,项目名称:MailShake,代码行数:10,代码来源:test_message.py

示例5: test_multiple_recipients

# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import render [as 别名]
def test_multiple_recipients():
    email = EmailMessage('Subject', 'Content', '[email protected]',
                         ['[email protected]', '[email protected]'])
    message = email.render()

    assert message['Subject'] == 'Subject'
    assert message.get_payload() == 'Content'
    assert message['From'] == '[email protected]'
    assert message['To'] == ('[email protected], [email protected]')
开发者ID:jpscaletti,项目名称:MailShake,代码行数:11,代码来源:test_message.py

示例6: test_from_header

# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import render [as 别名]
def test_from_header():
    """Make sure we can manually set the From header.
    """
    email = EmailMessage('Subject', 'Content', '[email protected]',
                         '[email protected]',
                         headers={'From': '[email protected]'})
    message = email.render()

    assert message['From'] == '[email protected]'
开发者ID:jpscaletti,项目名称:MailShake,代码行数:11,代码来源:test_message.py

示例7: test_ascii

# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import render [as 别名]
def test_ascii():
    email = EmailMessage('Subject', 'Content', '[email protected]',
                         '[email protected]')
    message = email.render()

    assert message['Subject'] == 'Subject'
    assert message.get_payload() == 'Content'
    assert message['From'] == '[email protected]'
    assert message['To'] == '[email protected]'
开发者ID:jpscaletti,项目名称:MailShake,代码行数:11,代码来源:test_message.py

示例8: test_invalid_destination

# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import render [as 别名]
def test_invalid_destination():
    dest = 'toБ@example.com'
    email = EmailMessage('Subject', 'Content', '[email protected]', dest)
    message = email.render()

    assert message['Subject'] == 'Subject'
    assert message.get_payload() == 'Content'
    assert message['From'] == '[email protected]'
    assert message['To'] != dest
开发者ID:jpscaletti,项目名称:MailShake,代码行数:11,代码来源:test_message.py

示例9: test_multiple_bcc

# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import render [as 别名]
def test_multiple_bcc():
    email = EmailMessage('Subject', 'Content', '[email protected]',
                         bcc=['[email protected]', '[email protected]'])
    message = email.render()

    assert not message['To']
    assert not message['Cc']
    assert not message['Bcc']  # as it should
    assert email.get_recipients() == ['[email protected]', '[email protected]']
开发者ID:jpscaletti,项目名称:MailShake,代码行数:11,代码来源:test_message.py

示例10: test_cc

# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import render [as 别名]
def test_cc():
    email = EmailMessage('Subject', 'Content', '[email protected]',
                         cc='[email protected]')
    message = email.render()

    assert message['Cc'] == '[email protected]'
    assert not message['To']
    assert not message['Bcc']
    assert email.get_recipients() == ['[email protected]']
开发者ID:jpscaletti,项目名称:MailShake,代码行数:11,代码来源:test_message.py

示例11: test_multiple_cc

# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import render [as 别名]
def test_multiple_cc():
    email = EmailMessage('Subject', 'Content', '[email protected]',
                         cc=['[email protected]', '[email protected]'])
    message = email.render()

    print(message['Cc'])
    assert message['Cc'] == '[email protected], [email protected]'
    assert not message['To']
    assert not message['Bcc']
    assert email.get_recipients() == ['[email protected]', '[email protected]']
开发者ID:jpscaletti,项目名称:MailShake,代码行数:12,代码来源:test_message.py

示例12: test_multiple_replyto

# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import render [as 别名]
def test_multiple_replyto():
    email = EmailMessage('Subject', 'Content', '[email protected]',
                         reply_to=['[email protected]', '[email protected]'])
    message = email.render()

    assert message['Reply-To'] == '[email protected], [email protected]'
    assert not message['To']
    assert not message['Cc']
    assert not message['Bcc']  # as it should
    assert email.get_recipients() == []
开发者ID:jpscaletti,项目名称:MailShake,代码行数:12,代码来源:test_message.py

示例13: test_unicode_headers

# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import render [as 别名]
def test_unicode_headers():
    headers = {
        'Sender': '"Firstname Sürname" <[email protected]>',
        'Comments': 'My Sürname is non-ASCII',
    }
    email = EmailMessage(u"Gżegżółka", "Content", "[email protected]",
                         "[email protected]", headers=headers)
    message = email.render()

    assert message['Subject'] == '=?utf-8?b?R8W8ZWfFvMOzxYJrYQ==?='
    assert message['Sender'] == '=?utf-8?q?Firstname_S=C3=BCrname?= <[email protected]>'
    assert message['Comments'] == '=?utf-8?q?My_S=C3=BCrname_is_non-ASCII?='
开发者ID:jpscaletti,项目名称:MailShake,代码行数:14,代码来源:test_message.py

示例14: test_encoding

# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import render [as 别名]
def test_encoding():
    """Encode body correctly with other encodings
    than utf-8
    """
    email = EmailMessage('Subject', 'Firstname Sürname is a great guy.',
                         '[email protected]', '[email protected]')
    email.encoding = 'iso-8859-1'
    message = email.render()

    assert message.as_string().startswith(
        'Content-Type: text/plain; charset="iso-8859-1"'
        '\nMIME-Version: 1.0'
        '\nContent-Transfer-Encoding: quoted-printable'
        '\nSubject: Subject'
        '\nFrom: [email protected]'
        '\nTo: [email protected]')
    assert message.get_payload() == 'Firstname S=FCrname is a great guy.'

    # Make sure MIME attachments also works correctly with other encodings than utf-8
    text_content = 'Firstname Sürname is a great guy.'
    html_content = '<p>Firstname Sürname is a <strong>great</strong> guy.</p>'

    email = EmailMessage('Subject', text_content, '[email protected]',
                         '[email protected]', html_content=html_content)
    email.encoding = 'iso-8859-1'
    message = email.render()

    assert message.get_payload(0).as_string() == (
        'Content-Type: text/plain; charset="iso-8859-1"'
        '\nMIME-Version: 1.0'
        '\nContent-Transfer-Encoding: quoted-printable'
        '\n\nFirstname S=FCrname is a great guy.')
    assert message.get_payload(1).as_string() == (
        'Content-Type: text/html; charset="iso-8859-1"'
        '\nMIME-Version: 1.0'
        '\nContent-Transfer-Encoding: quoted-printable'
        '\n\n<p>Firstname S=FCrname is a <strong>great</strong> guy.</p>')
开发者ID:jpscaletti,项目名称:MailShake,代码行数:39,代码来源:test_message.py

示例15: test_multiple_to_cc_bcc

# 需要导入模块: from mailshake import EmailMessage [as 别名]
# 或者: from mailshake.EmailMessage import render [as 别名]
def test_multiple_to_cc_bcc():
    email = EmailMessage('Subject', 'Content', '[email protected]',
                         to=['[email protected]', '[email protected]'],
                         cc=['[email protected]', '[email protected]'],
                         bcc=['[email protected]', '[email protected]'])
    message = email.render()

    assert message['To'] == '[email protected], [email protected]'
    assert message['Cc'] == '[email protected], [email protected]'
    assert message['Bcc'] == '[email protected], [email protected]'
    assert email.get_recipients() == [
        '[email protected]', '[email protected]',
        '[email protected]', '[email protected]',
        '[email protected]', '[email protected]',
    ]
开发者ID:alfredo,项目名称:MailShake,代码行数:17,代码来源:test_message.py


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