From 3865c5f887ca21ac0c55a71db047db57124f1f48 Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Mon, 20 May 2019 23:59:26 +0200 Subject: [PATCH] Handle message/delivery-status --- mbox2web | 14 ++++++++++++++ templates/body_message_delivery_status.html | 10 ++++++++++ 2 files changed, 24 insertions(+) create mode 100644 templates/body_message_delivery_status.html diff --git a/mbox2web b/mbox2web index 6f7d273..35ffa77 100755 --- a/mbox2web +++ b/mbox2web @@ -374,6 +374,19 @@ def render_body(msg, extra=None): def render_image_jpeg(msg, extra=None): return save_part(msg, "inline") + def render_message_delivery_status(msg, extra=None): + bodytmpl = jenv.get_template("body_message_delivery_status.html") + # A message/delivery status consists of one per-message block + # followed by one or more per-recipient blocks. + # Pythons message parser apparently parses each block as a message + # consisting only of headers. So we just stringify and concatenate them + parts = msg.get_payload() + parttext = "".join([str(p) for p in parts]) + context = { + "body": parttext + } + return bodytmpl.render(context) + renderers = { "text/plain": render_text_plain, "multipart/mixed": render_multipart_mixed, @@ -395,6 +408,7 @@ def render_body(msg, extra=None): "application/x-java-vm": render_application_octet_stream, "image/jpeg": render_image_jpeg, "application/x-compressed-tar": render_application_octet_stream, + "message/delivery-status": render_message_delivery_status, } content_type = msg.get_content_type() content_disposition = msg.get_content_disposition() diff --git a/templates/body_message_delivery_status.html b/templates/body_message_delivery_status.html new file mode 100644 index 0000000..5c2116b --- /dev/null +++ b/templates/body_message_delivery_status.html @@ -0,0 +1,10 @@ +
+
+ message/delivery-status +
+
+
+{{body}}
+
+
+