Handle message/delivery-status

This commit is contained in:
Peter J. Holzer 2019-05-20 23:59:26 +02:00
parent 35e8266695
commit 3865c5f887
2 changed files with 24 additions and 0 deletions

View File

@ -374,6 +374,19 @@ def render_body(msg, extra=None):
def render_image_jpeg(msg, extra=None): def render_image_jpeg(msg, extra=None):
return save_part(msg, "inline") 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 = { renderers = {
"text/plain": render_text_plain, "text/plain": render_text_plain,
"multipart/mixed": render_multipart_mixed, "multipart/mixed": render_multipart_mixed,
@ -395,6 +408,7 @@ def render_body(msg, extra=None):
"application/x-java-vm": render_application_octet_stream, "application/x-java-vm": render_application_octet_stream,
"image/jpeg": render_image_jpeg, "image/jpeg": render_image_jpeg,
"application/x-compressed-tar": render_application_octet_stream, "application/x-compressed-tar": render_application_octet_stream,
"message/delivery-status": render_message_delivery_status,
} }
content_type = msg.get_content_type() content_type = msg.get_content_type()
content_disposition = msg.get_content_disposition() content_disposition = msg.get_content_disposition()

View File

@ -0,0 +1,10 @@
<div class="partouter">
<div class="partheader">
message/delivery-status
</div>
<div class="partinner">
<pre>
{{body}}
</pre>
</div>
</div>