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