diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2012-02-16 09:23:11 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2012-02-16 21:56:17 +0000 |
commit | 7b42d592d33c165793d194ed0eee933d43f85394 (patch) | |
tree | cbba53c722e6a788eda0531378a5adeb8b09cda0 | |
parent | 7cf8462329cc1f73780754c842fbdd984290d098 (diff) |
move adding Date headers to save/send commands
This moves the addition of a Date header from Envelope.construct_mail
to the envelope handling commands. This allows us to store
mails locally that contain this timestamp, but send out mails
that do not so that the MTA, that will append its own timestamp,
doesn not create a second entry.
issue #326
-rw-r--r-- | alot/commands/envelope.py | 5 | ||||
-rw-r--r-- | alot/message.py | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py index f67f8f8f..81544629 100644 --- a/alot/commands/envelope.py +++ b/alot/commands/envelope.py @@ -92,6 +92,8 @@ class SaveCommand(Command): mail = envelope.construct_mail() # store mail locally + # add Date header + mail['Date'] = email.Utils.formatdate(localtime=True) path = account.store_draft_mail(mail) ui.notify('draft saved successfully') @@ -141,6 +143,9 @@ class SendCommand(Command): ui.apply_command(commands.globals.BufferCloseCommand()) ui.notify('mail sent successfully') # store mail locally + # add Date header + if 'Date' not in mail: + mail['Date'] = email.Utils.formatdate(localtime=True) path = account.store_sent_mail(mail) # add mail to index if maildir path available if path is not None: diff --git a/alot/message.py b/alot/message.py index 30b33535..4124e236 100644 --- a/alot/message.py +++ b/alot/message.py @@ -590,9 +590,7 @@ class Envelope(object): msg = textpart headers = self.headers.copy() - # add Date and Message-ID headers - if 'Date' not in headers: - headers['Date'] = [email.Utils.formatdate()] + # add Message-ID if 'Message-ID' not in headers: headers['Message-ID'] = [email.Utils.make_msgid()] |