| 1 | # coding: utf-8 |
| 2 | r""" |
| 3 | # Tests for the django.core.mail. |
| 4 | |
| 5 | >>> from django.core.mail import EmailMessage |
| 6 | |
| 7 | # Test normal ascii character case: |
| 8 | |
| 9 | >>> email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com']) |
| 10 | >>> message = email.message() |
| 11 | >>> str(message['Subject']) |
| 12 | 'Subject' |
| 13 | >>> str(message.get_payload()) |
| 14 | 'Content' |
| 15 | >>> str(message['From']) |
| 16 | 'from@example.com' |
| 17 | >>> str(message['To']) |
| 18 | 'to@example.com' |
| 19 | |
| 20 | # Test for header injection |
| 21 | |
| 22 | >>> email = EmailMessage('Subject\nInjection Test', 'Content', 'from@example.com', ['to@example.com']) |
| 23 | >>> message = email.message() |
| 24 | Traceback (most recent call last): |
| 25 | ... |
| 26 | BadHeaderError: Header values can't contain newlines (got 'Subject\nInjection Test' for header 'Subject') |
| 27 | |
| 28 | """ |