Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.1.X] Fixed #13259 -- Ensure that multiple calls to message() don't…

… corrupt any extra message headers. Thanks to canburak for the report, and Andi Albrecht for the fix.

Backport of r12901 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12902 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 33052458c579568b76a120ae7fdd0197791a8462 1 parent fa11430
@freakboy3742 freakboy3742 authored
Showing with 13 additions and 1 deletion.
  1. +3 −1 django/core/mail.py
  2. +10 −0 tests/regressiontests/mail/tests.py
View
4 django/core/mail.py
@@ -249,7 +249,7 @@ def message(self):
self.content_subtype, encoding)
msg = self._create_message(msg)
msg['Subject'] = self.subject
- msg['From'] = self.extra_headers.pop('From', self.from_email)
+ msg['From'] = self.extra_headers.get('From', self.from_email)
msg['To'] = ', '.join(self.to)
# Email header names are case-insensitive (RFC 2045), so we have to
@@ -260,6 +260,8 @@ def message(self):
if 'message-id' not in header_names:
msg['Message-ID'] = make_msgid()
for name, value in self.extra_headers.items():
+ if name.lower() == 'from':
+ continue
msg[name] = value
return msg
View
10 tests/regressiontests/mail/tests.py
@@ -95,6 +95,16 @@
>>> message['From']
'from@example.com'
+# Regression for #13259 - Make sure that headers are not changed
+# when calling EmailMessage.message()
+>>> email = EmailMessage('Subject', 'Content', 'bounce@example.com', ['to@example.com'], headers={'From': 'from@example.com'})
+>>> message = email.message()
+>>> message['From']
+'from@example.com'
+>>> message = email.message()
+>>> message['From']
+'from@example.com'
+
# Regression for #11144 - When a to/from/cc header contains unicode,
# make sure the email addresses are parsed correctly (especially
# with regards to commas)
Please sign in to comment.
Something went wrong with that request. Please try again.