limap/test.lua

44 lines
1.3 KiB
Lua
Raw Normal View History

2022-08-26 19:40:12 +02:00
local OP_DEBUG = 0x1
local OP_READONLY = 0x2
local OP_ANONYMOUS = 0x4 --/* anonymous open of newsgroup */
local OP_SHORTCACHE = 0x8 --/* short (elt-only) caching */
local OP_SILENT = 0x10 --/* don't pass up events (internal use) */
local OP_PROTOTYPE = 0x20 --/* return driver prototype */
local OP_HALFOPEN = 0x40 --/* half-open (IMAP connect but no select) */
local OP_EXPUNGE= 0x80 --/* silently expunge recycle stream */
local imap = require("limap")
local passwd = os.getenv("IMAP_PWD") or "!x$@n9ph"
local url = string.format("{iohub.dev:143/imap/tls-sslv23/novalidate-cert/user=mrsang;%s}",passwd);
local handle, box = imap.open(url,OP_HALFOPEN|OP_DEBUG)
local r,v = false,nil;
if(handle) then
print("mailbox openned")
local boxes = imap.get_mail_boxes(handle, box:gsub("[^}]*$",""),"*");
for k, v in ipairs(boxes) do
print("=================")
for k1, v1 in pairs(v) do
print(k1,v1)
end
end
r, box = imap.reopen(handle,box:gsub("[^}]*$","INBOX"), OP_DEBUG)
if r then
print("new box opened", box)
else
print("reopen failed")
end
r,v = imap.ping(handle)
if r then
print("Alive", v)
else
print("Unable to ping")
end
imap.check(handle);
imap.close(handle)
end