diff options
author | Paul Rodger <paul@paulrodger.com> | 2002-04-03 11:12:25 +0000 |
---|---|---|
committer | Paul Rodger <paul@paulrodger.com> | 2002-04-03 11:12:25 +0000 |
commit | 16999ce35b2d63a9e611aa45000e12d28889dd69 (patch) | |
tree | 0fbd465b7c276dae0d9bd2ae7dcf49f38e200d2f | |
parent | 68b96c21202aa2be6ab351156a2e6e0b64fe59af (diff) | |
download | archivemail-16999ce35b2d63a9e611aa45000e12d28889dd69.tar.gz archivemail-16999ce35b2d63a9e611aa45000e12d28889dd69.tar.bz2 archivemail-16999ce35b2d63a9e611aa45000e12d28889dd69.zip |
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.
-rwxr-xr-x | archivemail.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/archivemail.py b/archivemail.py index db090dc..948c116 100755 --- a/archivemail.py +++ b/archivemail.py @@ -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) |