aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/lumail2/lumail2.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/config/lumail2/lumail2.lua b/config/lumail2/lumail2.lua
index 8e66daf..8466863 100644
--- a/config/lumail2/lumail2.lua
+++ b/config/lumail2/lumail2.lua
@@ -200,3 +200,29 @@ do
end
end
+--
+-- Add Content-Type to the headers before sending
+--
+function on_message_send(path)
+ local content = {}
+ local added = false
+ local is_header = "^%a+: .*"
+ for l in io.lines(path) do
+ -- Find the last header.
+ if not added
+ and content[#content] and string.match(content[#content], is_header)
+ and not string.match(l, is_header)
+ then
+ -- Append Content-Type to the headers.
+ table.insert(content, "Content-Type: text/plain; charset=UTF-8\n")
+ added = true
+ end
+ table.insert(content, l.."\n")
+ end
+
+ -- write the new content
+ local m = io.open(path, "w")
+ m:write(unpack(content))
+ m:close()
+end
+