Lua
Lua
Log Out of an IMAP Server
See more IMAP Examples
Demonstrates the Chilkat Imap.Logout method, which sends the IMAP LOGOUT command and ends the authenticated session. The server normally closes the connection as part of a successful logout. This example connects, logs in, logs out, and disconnects.
Background:
LOGOUT is the polite way to end an IMAP session — it tells the server you are finished so it can release the session's resources and close the socket gracefully, rather than treating the disconnect as an abrupt drop. It is the counterpart to Login; calling Disconnect afterward ensures the local socket is fully closed.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- Demonstrates the Imap.Logout method, which sends the IMAP LOGOUT command and ends the
-- authenticated session. The server normally closes the connection as part of a successful
-- logout.
local imap = chilkat.Imap.new()
imap.ssl = true
imap.port = 993
local success = imap:connect("imap.example.com")
if not success then
print(imap.last_error_text)
return
end
success = imap:login("user@example.com", "myPassword")
if not success then
print(imap.last_error_text)
return
end
-- End the authenticated session.
success = imap:logout()
if not success then
print(imap.last_error_text)
return
end
-- Close the connection.
success = imap:disconnect()
if not success then
print(imap.last_error_text)
return
end
print("Logged out and disconnected.")