imapnotify

imapnotify.conf.lua at tip

File imapnotify.conf.lua from the latest check-in


--[[ imapnotify
A simple lua script to trigger a notification on a new mail in an imap mailbox.
For tls/starttls, stunnel needs to be used - see stunnel_imapnotify.conf
]]
user = ""
pass = ""
--host = "127.0.0.1"
--port = 143
--mbox = "INBOX"
-- updateUnseen callback gets triggered, if UNSEEN mailcount is changed
--updateUnseen = function(unseen_count) end
--[[ fetch_header will fetch headers and provide the notify_table:
  notify_table = {
    from = "...",
    subject = "...",
    ...
  }
  if fetch_header is empty mailNotify callback will not get triggered
]]
--fetch_header = {"from", "subject"}
--[=[
-- mailNotify callback gets triggered once for every UNSEEN mail
-- need locals, _ENV = nil
local execute = os.execute
local date = os.date
local popen = io.popen
local format = string.format
mailNotify = function(notify_table)
  --execute(format([[notify "%s - %s: \"%s\""]], date(), notify_table.from, notify_table.subject))
  notify = popen("notify", "w")
  notify:write(format("%s - %s: \"%s\"", date(), notify_table.from, notify_table.subject))
  notify:close()
end
--]=]