本文整理汇总了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()
示例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]']
示例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
示例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'
示例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]'
示例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'
示例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]')
示例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]']
示例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
示例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]']
示例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]']
示例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]'
示例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() == []
示例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]']
示例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]']