[pmg-devel] [PATCH pmg-api 2/2] utils: finalize_report: change order of plain and html parts

Stoiko Ivanov s.ivanov at proxmox.com
Mon Oct 13 13:06:19 CEST 2025


After 2 reports and a hint in our community forum [0] that the reports
are displayed differently since the upgrade - I checked the MIME-RFC:
https://datatracker.ietf.org/doc/html/rfc2046#section-5.1.4

which suggests to add the most preferred alternative last (so that
text/plain comes in the beginning which is nicer to view for
mail-clients which do not handle MIME at all).

I had chalked this up to my MUAs preferring text/plain where possible.

Tested this by comparing a spamreport sent with this patch applied in
* claws-mail
* mutt
* bluemind webmail
* aerc

[0] https://forum.proxmox.com/threads/.173435/
Fixes: 542f7279 ("utils: allow specifying plain and/or html for finalize_report()")
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 src/PMG/Utils.pm | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/PMG/Utils.pm b/src/PMG/Utils.pm
index a2cd3fc4..52b98c01 100644
--- a/src/PMG/Utils.pm
+++ b/src/PMG/Utils.pm
@@ -1370,13 +1370,6 @@ sub finalize_report {
         Subject => bencode_header(decode_entities($title)),
     );
 
-    if ($html) {
-        $top->attach(
-            Data => $html,
-            Type => "text/html",
-            Encoding => $debug ? 'binary' : 'quoted-printable',
-        );
-    }
     if ($plaintext) {
         $top->attach(
             Data => $plaintext,
@@ -1384,6 +1377,13 @@ sub finalize_report {
             Encoding => '8-bit',
         );
     }
+    if ($html) {
+        $top->attach(
+            Data => $html,
+            Type => "text/html",
+            Encoding => $debug ? 'binary' : 'quoted-printable',
+        );
+    }
 
     $top->head()->add('Auto-Submitted', 'auto-generated');
 
-- 
2.47.3





More information about the pmg-devel mailing list