|
20 | 20 | from modoboa.lib import u2u_decode |
21 | 21 | from modoboa.lib.email_utils import Email, EmailAddress |
22 | 22 |
|
23 | | -from .. import constants |
24 | 23 | from . import imapheader |
25 | 24 | from .attachments import get_storage_path |
26 | 25 | from .imaputils import ( |
@@ -96,7 +95,11 @@ def get_header(self, msg, hdrname, **kwargs): |
96 | 95 |
|
97 | 96 | We also try to decode the default value. |
98 | 97 | """ |
99 | | - hdrvalue = super(ImapEmail, self).get_header(msg, hdrname) |
| 98 | + hdrvalue = super().get_header(msg, hdrname) |
| 99 | + if hdrname in ["From", "Reply-To"]: |
| 100 | + # Store a raw copy for further use |
| 101 | + setattr(self, "original_{}".format(hdrname.replace("-", "")), |
| 102 | + hdrvalue) |
100 | 103 | if not hdrvalue: |
101 | 104 | return "" |
102 | 105 | try: |
@@ -275,17 +278,17 @@ class ReplyModifier(Modifier): |
275 | 278 | ] |
276 | 279 |
|
277 | 280 | def __init__(self, *args, **kwargs): |
278 | | - super(ReplyModifier, self).__init__(*args, **kwargs) |
| 281 | + super().__init__(*args, **kwargs) |
279 | 282 |
|
280 | 283 | self.textheader = u"%s %s" % (self.From, _("wrote:")) |
281 | 284 | if self.dformat == "html": |
282 | 285 | self.textheader = u"<p>{}</p>".format(self.textheader) |
283 | 286 | if hasattr(self, "Message_ID"): |
284 | 287 | self.form.fields["origmsgid"].initial = self.Message_ID |
285 | 288 | if not hasattr(self, "Reply_To"): |
286 | | - self.form.fields["to"].initial = self.From |
| 289 | + self.form.fields["to"].initial = self.original_From |
287 | 290 | else: |
288 | | - self.form.fields["to"].initial = self.Reply_To |
| 291 | + self.form.fields["to"].initial = self.original_ReplyTo |
289 | 292 | if self.request.GET.get("all", "0") == "1": # reply-all |
290 | 293 | self.form.fields["cc"].initial = "" |
291 | 294 | toparse = self.To.split(",") |
|
0 commit comments