Commit 8ada8d7c authored by Jacob Kaplan-Moss's avatar Jacob Kaplan-Moss
Browse files

Fixed #9214: EmailMessage now respects the From header instead of blindly...

Fixed #9214: EmailMessage now respects the From header instead of blindly using from_email. Thanks, Tai Lee.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9842 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent ecc55503
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+7 −0
Original line number Diff line number Diff line
@@ -88,4 +88,11 @@ BadHeaderError: Header values can't contain newlines (got u'Subject\nInjection T
>>> settings.ADMINS = old_admins
>>> settings.MANAGERS = old_managers

# 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'

"""