summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2011-12-27 01:38:18 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2011-12-27 01:38:18 +0000
commitf954f91f5d9d535684cf5b687aafbacd67938744 (patch)
tree255e7f6f2cb1071726143ac09e3969ff8de46497 /alot
parent950cb2116d3855435fcf1424a5b597f2436e811f (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.py4
-rw-r--r--alot/message.py10
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)