🐛 Change internal ordering on how email parts are assembled

This fixes the html email rendering on gmail. Other clients (like proton,
emailcatcher) properly renders html independently of the order of parts
on the multipart email structure but gmail requires that html should be
the last one.
This commit is contained in:
Andrey Antukh
2025-12-01 14:19:02 +01:00
parent 529c4eb38a
commit 95b7784a42

View File

@@ -106,17 +106,17 @@
(let [content-part (MimeBodyPart.) (let [content-part (MimeBodyPart.)
alternative-mpart (MimeMultipart. "alternative")] alternative-mpart (MimeMultipart. "alternative")]
(when-let [content (get body "text/plain")]
(let [text-part (MimeBodyPart.)]
(.setText text-part ^String content ^String charset)
(.addBodyPart alternative-mpart text-part)))
(when-let [content (get body "text/html")] (when-let [content (get body "text/html")]
(let [html-part (MimeBodyPart.)] (let [html-part (MimeBodyPart.)]
(.setContent html-part ^String content (.setContent html-part ^String content
(str "text/html; charset=" charset)) (str "text/html; charset=" charset))
(.addBodyPart alternative-mpart html-part))) (.addBodyPart alternative-mpart html-part)))
(when-let [content (get body "text/plain")]
(let [text-part (MimeBodyPart.)]
(.setText text-part ^String content ^String charset)
(.addBodyPart alternative-mpart text-part)))
(.setContent content-part alternative-mpart) (.setContent content-part alternative-mpart)
(.addBodyPart mixed-mpart content-part)) (.addBodyPart mixed-mpart content-part))