Skip to content

Commit

Permalink
[1.0.X] Fixed #9214: EmailMessage now respects the From header instea…
Browse files Browse the repository at this point in the history
…d 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
  • Loading branch information
jacobian committed Feb 24, 2009
1 parent bd2e7a7 commit 734376f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django/core/mail.py
Expand Up @@ -245,7 +245,7 @@ def message(self):
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
Expand Down
7 changes: 7 additions & 0 deletions tests/regressiontests/mail/tests.py
Expand Up @@ -60,4 +60,11 @@
>>> 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'
"""

0 comments on commit 734376f

Please sign in to comment.