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


Python mailshake.EmailMessage类代码示例

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


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

示例1: test_dont_base64_encode

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,代码行数:7,代码来源:test_message.py

示例2: test_cc

def test_cc():
    email = EmailMessage('Subject', 'Content', '[email protected]',
        '[email protected]', cc='[email protected]')
    message = email.message()

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

示例3: test_dont_mangle_from_in_body

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]'})
    str_email = email.as_bytes()
    print(str_email)
    assert b'>From the future' not in str_email
开发者ID:jpscaletti,项目名称:MailShake,代码行数:8,代码来源:test_message.py

示例4: test_space_continuation

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.message()

    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:andrewnelder,项目名称:MailShake,代码行数:8,代码来源:test_message.py

示例5: test_from_header

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.message()

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

示例6: test_message_header_overrides

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,代码行数:9,代码来源:test_message.py

示例7: test_multiple_recipients

def test_multiple_recipients():
    email = EmailMessage('Subject', 'Content', '[email protected]',
                         ['[email protected]', '[email protected]m'])
    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,代码行数:9,代码来源:test_message.py

示例8: test_multiple_cc_and_to

def test_multiple_cc_and_to():
    email = EmailMessage('Subject', 'Content', '[email protected]',
        to=['[email protected]', '[email protected]'],
        cc=['[email protected]', '[email protected]'])
    message = email.message()

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

示例9: test_invalid_destination

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,代码行数:9,代码来源:test_message.py

示例10: test_multiple_bcc

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,代码行数:9,代码来源:test_message.py

示例11: test_cc

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,代码行数:9,代码来源:test_message.py

示例12: test_ascii

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,代码行数:9,代码来源:test_message.py

示例13: test_multiple_replyto

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,代码行数:10,代码来源:test_message.py

示例14: test_recipients_as_tuple

def test_recipients_as_tuple():
    email = EmailMessage('Subject', 'Content', '[email protected]', 
        to=('[email protected]', '[email protected]'),
        cc=('[email protected]', '[email protected]'),
        bcc=('[email protected]',))
    message = email.message()

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

示例15: test_multiple_cc

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,代码行数:10,代码来源:test_message.py


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