diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2009-02-24 17:02:03 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2009-02-24 17:02:03 +0000 |
| commit | 734376f9473693b87db0bdc30a725500db0fb181 (patch) | |
| tree | 69b55b0933c8aaeca5535cb8476ee3608411b443 | |
| parent | bd2e7a787626a4cb8a8ec9a225d6d558f557f02a (diff) | |
[1.0.X] Fixed #9214: EmailMessage now respects the From header instead of blindly using from_email. Thanks, Tai Lee.
Backport of r9842 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9900 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/core/mail.py | 2 | ||||
| -rw-r--r-- | tests/regressiontests/mail/tests.py | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/django/core/mail.py b/django/core/mail.py index 58588bf712..157474ff2c 100644 --- a/django/core/mail.py +++ b/django/core/mail.py @@ -245,7 +245,7 @@ class EmailMessage(object): else: msg.attach(self._create_attachment(*attachment)) msg['Subject'] = self.subject - msg['From'] = self.from_email + msg['From'] = self.extra_headers.pop('From', self.from_email) msg['To'] = ', '.join(self.to) # Email header names are case-insensitive (RFC 2045), so we have to diff --git a/tests/regressiontests/mail/tests.py b/tests/regressiontests/mail/tests.py index c2c084c4c6..083840f45e 100644 --- a/tests/regressiontests/mail/tests.py +++ b/tests/regressiontests/mail/tests.py @@ -60,4 +60,11 @@ BadHeaderError: Header values can't contain newlines (got u'Subject\nInjection T >>> email.message().as_string() 'Content-Type: text/plain; charset="utf-8"\nMIME-Version: 1.0\nContent-Transfer-Encoding: quoted-printable\nSubject: subject\nFrom: from@example.com\nTo: to@example.com\ndate: Fri, 09 Nov 2001 01:08:47 -0000\nMessage-ID: foo\n\ncontent' +# Make sure we can manually set the From header (#9214) + +>>> email = EmailMessage('Subject', 'Content', 'bounce@example.com', ['to@example.com'], headers={'From': 'from@example.com'}) +>>> message = email.message() +>>> message['From'] +'from@example.com' + """ |
