當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。