diff --git a/django/core/mail/message.py b/django/core/mail/message.py
index a288d6c..91a10a0 100644
a
|
b
|
class EmailMessage(object):
|
143 | 143 | self.content_subtype, encoding) |
144 | 144 | msg = self._create_message(msg) |
145 | 145 | msg['Subject'] = self.subject |
146 | | msg['From'] = self.extra_headers.pop('From', self.from_email) |
| 146 | msg['From'] = self.extra_headers.get('From', self.from_email) |
147 | 147 | msg['To'] = ', '.join(self.to) |
148 | 148 | |
149 | 149 | # Email header names are case-insensitive (RFC 2045), so we have to |
… |
… |
class EmailMessage(object):
|
154 | 154 | if 'message-id' not in header_names: |
155 | 155 | msg['Message-ID'] = make_msgid() |
156 | 156 | for name, value in self.extra_headers.items(): |
| 157 | if name.lower() == 'from': # From is already handled |
| 158 | continue |
157 | 159 | msg[name] = value |
158 | 160 | return msg |
159 | 161 | |
diff --git a/tests/regressiontests/mail/tests.py b/tests/regressiontests/mail/tests.py
index e27804c..84be585 100644
a
|
b
|
BadHeaderError: Header values can't contain newlines (got u'Subject\nInjection T
|
101 | 101 | >>> message['From'] |
102 | 102 | 'from@example.com' |
103 | 103 | |
| 104 | # Regression for #13259 - Make sure that headers are not changed |
| 105 | # when calling EmailMessage.message() |
| 106 | >>> email = EmailMessage('Subject', 'Content', 'bounce@example.com', ['to@example.com'], headers={'From': 'from@example.com'}) |
| 107 | >>> message = email.message() |
| 108 | >>> message['From'] |
| 109 | 'from@example.com' |
| 110 | >>> message = email.message() |
| 111 | >>> message['From'] |
| 112 | 'from@example.com' |
| 113 | |
104 | 114 | # Regression for #11144 - When a to/from/cc header contains unicode, |
105 | 115 | # make sure the email addresses are parsed correctly (especially |
106 | 116 | # with regards to commas) |