[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
This commit is contained in:
parent
bd2e7a7876
commit
734376f947
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue