mirror of
https://github.com/django/django.git
synced 2024-12-27 03:25:58 +00:00
f49c5c23f9
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8083 bcc190cf-cafb-0310-a4f2-bffc1f526a37
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
# coding: utf-8
|
|
r"""
|
|
# Tests for the django.core.mail.
|
|
|
|
>>> from django.core.mail import EmailMessage
|
|
>>> from django.utils.translation import ugettext_lazy
|
|
|
|
# Test normal ascii character case:
|
|
|
|
>>> email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com'])
|
|
>>> message = email.message()
|
|
>>> message['Subject']
|
|
'Subject'
|
|
>>> message.get_payload()
|
|
'Content'
|
|
>>> message['From']
|
|
'from@example.com'
|
|
>>> message['To']
|
|
'to@example.com'
|
|
|
|
# Test multiple-recipient case
|
|
|
|
>>> email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com','other@example.com'])
|
|
>>> message = email.message()
|
|
>>> message['Subject']
|
|
'Subject'
|
|
>>> message.get_payload()
|
|
'Content'
|
|
>>> message['From']
|
|
'from@example.com'
|
|
>>> message['To']
|
|
'to@example.com, other@example.com'
|
|
|
|
# Test for header injection
|
|
|
|
>>> email = EmailMessage('Subject\nInjection Test', 'Content', 'from@example.com', ['to@example.com'])
|
|
>>> message = email.message()
|
|
Traceback (most recent call last):
|
|
...
|
|
BadHeaderError: Header values can't contain newlines (got u'Subject\nInjection Test' for header 'Subject')
|
|
|
|
>>> email = EmailMessage(ugettext_lazy('Subject\nInjection Test'), 'Content', 'from@example.com', ['to@example.com'])
|
|
>>> message = email.message()
|
|
Traceback (most recent call last):
|
|
...
|
|
BadHeaderError: Header values can't contain newlines (got u'Subject\nInjection Test' for header 'Subject')
|
|
|
|
"""
|