Lua
Lua
Send a POP3 RSET to Unmark Deletions
See more POP3 Examples
Demonstrates the Chilkat MailMan.Pop3Reset method, which sends the POP3 RSET command to the server. Any messages marked for deletion during the current session are unmarked and remain in the mailbox, and the POP3 session stays open. This example marks a message for deletion, then clears the mark with RSET.
Background:
RSET is POP3's in-session undo for deletion marks. It differs from Pop3EndSessionNoQuit, which also discards pending deletions but closes the connection. With RSET the authenticated session continues, so you can clear the marks and keep working — handy when a processing step fails partway and you want to retry without reconnecting.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- Demonstrates the MailMan.Pop3Reset method, which sends the POP3 RSET command. Any
-- messages marked for deletion during the current session are unmarked and remain in the
-- mailbox. The POP3 session stays open.
local mailman = chilkat.MailMan.new()
-- Configure the POP3 server connection.
mailman.mail_host = "pop.example.com"
mailman.mail_port = 995
mailman.pop_ssl = true
mailman.pop_username = "user@example.com"
mailman.pop_password = "myPassword"
local success = mailman:pop3_begin_session()
if not success then
print(mailman.last_error_text)
return
end
-- Mark a message for deletion...
success = mailman:delete_by_msgnum(1)
if not success then
print(mailman.last_error_text)
return
end
-- ...then change your mind: RSET unmarks all pending deletions but keeps the session open.
success = mailman:pop3_reset()
if not success then
print(mailman.last_error_text)
return
end
-- Ending the session now commits nothing, because the marks were cleared.
success = mailman:pop3_end_session()
if not success then
print(mailman.last_error_text)
return
end
print("Pending deletions were unmarked with RSET.")