Lua Requires Chilkat v9.5.0.58+
Lua
IMAP Capability
Demonstrates how to send the CAPABILITY command to request a listing of capabilities that the IMAP server supports. A capability name which begins with "AUTH=" indicates that the server supports that particular authentication mechanism.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local imap = chilkat.Imap.new()
-- Use TLS
imap.ssl = true
imap.port = 993
local success = imap:connect("MY-IMAP-DOMAIN")
if not success then
print(imap.last_error_text)
return
end
-- Authenticate
success = imap:login("MY-IMAP-LOGIN", "MY-IMAP-PASSWORD")
if not success then
print(imap.last_error_text)
return
end
-- Get the list of capabilities:
local caps = imap:capability()
print("Capabilities: " .. caps)
-- Here is an example of the string returned:
-- * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1
-- UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT APPENDLIMIT=35882577
-- LIST-EXTENDED LIST-STATUS
-- The HasCapability method can be used to
-- check to see if a particular capability exists:
if imap:has_capability("QUOTA", caps) then
print("IMAP server supports the QUOTA extension.")
end
if imap:has_capability("IDLE", caps) then
print("IMAP server supports IDLE.")
end
-- Disconnect from the IMAP server.
success = imap:disconnect()