mirror of
https://git.code.sf.net/p/archivemail/code
synced 2025-01-03 05:34:58 +00:00
Don't assume we will always have a Delivery-Date header when constructing
the 'From_' line from a 'maildir' folder. Use the 'Date' header when we dont.
This commit is contained in:
parent
68b96c2120
commit
16999ce35b
1 changed files with 13 additions and 2 deletions
|
@ -582,19 +582,30 @@ def make_mbox_from(message):
|
|||
vprint("make_mbox_from: no Return-path -- using 'From:' instead!")
|
||||
address_header = message.get('From')
|
||||
(name, address) = rfc822.parseaddr(address_header)
|
||||
date = rfc822.parsedate(message.get('Delivery-date'))
|
||||
|
||||
date = None
|
||||
delivery_date_header = message.get('Delivery-date')
|
||||
if delivery_date_header:
|
||||
date = rfc822.parsedate(delivery_date_header)
|
||||
if not date:
|
||||
date = rfc822.parsedate(message.get('Date'))
|
||||
date_header = message.get('Date')
|
||||
if not date_header:
|
||||
unexpected_error("message has no 'Date' header")
|
||||
date = rfc822.parsedate(date_header)
|
||||
if not date:
|
||||
unexpected_error("message has no valid 'Date' header")
|
||||
date_string = time.asctime(date)
|
||||
mbox_from = "From %s %s\n" % (address, date_string)
|
||||
return mbox_from
|
||||
|
||||
|
||||
def get_date_mtime(message):
|
||||
"""Return the delivery date of an rfc822 message in a maildir mailbox"""
|
||||
assert(message)
|
||||
vprint("using last-modification time of message file")
|
||||
return os.path.getmtime(message.fp.name)
|
||||
|
||||
|
||||
def get_date_headers(message):
|
||||
"""Return the delivery date of an rfc822 message in a mbox mailbox"""
|
||||
assert(message)
|
||||
|
|
Loading…
Reference in a new issue