Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #9214: EmailMessage now respects the From header instead of bli…

…ndly using from_email. Thanks, Tai Lee.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9842 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 8ada8d7c0391572d0b1f0408394d041e59d19be4 1 parent ecc5550
Jacob Kaplan-Moss authored February 16, 2009
2  django/core/mail.py
@@ -245,7 +245,7 @@ def message(self):
245 245
                 else:
246 246
                     msg.attach(self._create_attachment(*attachment))
247 247
         msg['Subject'] = self.subject
248  
-        msg['From'] = self.from_email
  248
+        msg['From'] = self.extra_headers.pop('From', self.from_email)
249 249
         msg['To'] = ', '.join(self.to)
250 250
 
251 251
         # Email header names are case-insensitive (RFC 2045), so we have to
7  tests/regressiontests/mail/tests.py
@@ -88,4 +88,11 @@
88 88
 >>> settings.ADMINS = old_admins
89 89
 >>> settings.MANAGERS = old_managers
90 90
 
  91
+# Make sure we can manually set the From header (#9214)
  92
+
  93
+>>> email = EmailMessage('Subject', 'Content', 'bounce@example.com', ['to@example.com'], headers={'From': 'from@example.com'}) 
  94
+>>> message = email.message() 
  95
+>>> message['From']
  96
+'from@example.com'
  97
+
91 98
 """

0 notes on commit 8ada8d7

Please sign in to comment.
Something went wrong with that request. Please try again.