dotfiles/mail/.config/imapfilter/config.lua

42 lines
1.7 KiB
Lua
Raw Normal View History

-- According to the IMAP specification, when trying to write a message
-- to a non-existent mailbox, the server must send a hint to the client,
-- whether it should create the mailbox and try again or not. However
-- some IMAP servers don't follow the specification and don't send the
-- correct response code to the client. By enabling this option the
-- client tries to create the mailbox, despite of the server's response.
-- This variable takes a boolean as a value. Default is “false”.
options.create = true
-- By enabling this option new mailboxes that were automatically created,
-- get auto subscribed
options.subscribe = true
-- How long to wait for servers response.
options.timeout = 120
accounts = loadfile(os.getenv("HOME") .. "/.config/imapfilter/accounts.lua")()
-- will set filters to be grabbed from XDG-compliant filter directory
-- can be overridden with env var IMAPFILTER_FILTERDIR
function getFilterDir()
-- -- set directory for imapfilter files
local imapfilterdir
if os.getenv("IMAPFILTER_FILTERDIR") then
imapfilterdir=os.getenv("IMAPFILTER_FILTERDIR")
elseif os.getenv("XDG_CONFIG_HOME") then
imapfilterdir=os.getenv("XDG_CONFIG_HOME") .. "/imapfilter/filters"
else
imapfilterdir=os.getenv("HOME") .. "/.config/imapfilter/filters"
end
return imapfilterdir
end
local filters = {}
-- dirlist, from https://stackoverflow.com/a/25266573
function applyFilters(dir)
local p = io.popen('find "'..dir..'" -type f') --Open directory look for files, save data in p. By giving '-type f' as parameter, it returns all files.
for file in p:lines() do --Loop through all files
loadfile(file)()
end
end
applyFilters(getFilterDir())