diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2011-12-27 01:38:18 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2011-12-27 01:38:18 +0000 |
commit | f954f91f5d9d535684cf5b687aafbacd67938744 (patch) | |
tree | 255e7f6f2cb1071726143ac09e3969ff8de46497 /alot | |
parent | 950cb2116d3855435fcf1424a5b597f2436e811f (diff) |
move Message-ID creation to envelope.construct_mail
and clean up envelope.construct_mail a bit
issue #199
closes #199
Diffstat (limited to 'alot')
-rw-r--r-- | alot/commands/globals.py | 4 | ||||
-rw-r--r-- | alot/message.py | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py index 43441763..3536df29 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -566,10 +566,6 @@ class ComposeCommand(Command): return self.envelope.add('Subject', subject) - # get missing Message-ID header - if 'Message-ID' not in self.envelope.headers: - self.envelope.add('Message-ID', email.Utils.make_msgid()) - if self.attach: for a in self.attach: self.envelope.attach(a) diff --git a/alot/message.py b/alot/message.py index bd23cf3c..2aa9381a 100644 --- a/alot/message.py +++ b/alot/message.py @@ -540,11 +540,15 @@ class Envelope(object): else: msg = textpart - # add Date header - msg['Date'] = email.Utils.formatdate() + headers = self.headers.copy() + # add Date and Message-ID headers + if 'Date' not in headers: + headers['Date'] = [email.Utils.formatdate()] + if 'Message-ID' not in headers: + headers['Message-ID'] = [email.Utils.make_msgid()] # copy headers from envelope to mail - for k, vlist in self.headers.items(): + for k, vlist in headers.items(): for v in vlist: msg[k] = encode_header(k, v) |