From 621642a33b947cc29fa1aa48e5268385a9d582b3 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Tue, 6 Jun 2017 18:19:18 +0200 Subject: lumail2 add Content-Type to the headers --- config/lumail2/lumail2.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'config') 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 + -- cgit v1.2.3