It seems like calling msg:append_text_html() breaks the message content if Content-Transfer-Encoding is base64. I used the code below to make sure that it’s append_text_html that’s causing this:
if (track_opens and track_opens_header ~= "false") or track_opens_header == "true" then
if aha.cached_domain_has_tracking(domain) then
local my_tracking_link = string.format('<img src="https://t.%s/msg/%s/images/image.png" alt="t">', original_sender_domain, msg:id())
local f1 = io.open("/tmp/before-append-text.eml", "w")
f1:write(msg:get_data())
f1:close()
msg:append_text_html(my_tracking_link)
local f2 = io.open("/tmp/after-append-text.eml", "w")
f2:write(msg:get_data())
f2:close()
end
end
The message in before-append-text.eml is fine, the one in after-append-text.eml is garbled.
I can share the eml files privately if that helps.