Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.0.X] Fixed #9214: EmailMessage now respects the From header instea…

…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...
commit 734376f9473693b87db0bdc30a725500db0fb181 1 parent bd2e7a7
@jacobian jacobian authored
Showing with 8 additions and 1 deletion.
  1. +1 −1  django/core/mail.py
  2. +7 −0 tests/regressiontests/mail/tests.py
View
2  django/core/mail.py
@@ -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
View
7 tests/regressiontests/mail/tests.py
@@ -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'
+
"""
Please sign in to comment.
Something went wrong with that request. Please try again.