diff --git a/tests/regressiontests/mail/__init__.py b/tests/regressiontests/mail/__init__.py new file mode 100644 index 0000000000..139597f9cb --- /dev/null +++ b/tests/regressiontests/mail/__init__.py @@ -0,0 +1,2 @@ + + diff --git a/tests/regressiontests/mail/models.py b/tests/regressiontests/mail/models.py new file mode 100644 index 0000000000..7ff128fa69 --- /dev/null +++ b/tests/regressiontests/mail/models.py @@ -0,0 +1 @@ +# This file intentionally left blank \ No newline at end of file diff --git a/tests/regressiontests/mail/tests.py b/tests/regressiontests/mail/tests.py new file mode 100644 index 0000000000..9d2e2abe96 --- /dev/null +++ b/tests/regressiontests/mail/tests.py @@ -0,0 +1,41 @@ +# coding: utf-8 +r""" +# Tests for the django.core.mail. + +>>> from django.core.mail import EmailMessage + +# 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 'Subject\nInjection Test' for header 'Subject') + +"""