Sample code for 30+ languages & platforms
Tcl

End a POP3 Session (Commit Deletions)

See more POP3 Examples

Demonstrates the Chilkat MailMan.Pop3EndSession method, which ends the current POP3 session by sending the QUIT command. Ending the session normally commits any messages that were marked for deletion during the session. This example begins a session and then ends it.

Background: POP3 deletion is deferred: DELE commands only mark messages during the session, and the server permanently removes them when the client sends QUIT to end the session cleanly. Pop3EndSession is that commit point. If a session is dropped without QUIT (see Pop3EndSessionNoQuit), the server rolls back the pending deletions and the messages remain.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

#  Demonstrates the MailMan.Pop3EndSession method, which ends the current POP3 session by
#  sending the QUIT command.  Ending the session normally commits any messages that were
#  marked for deletion during the session.

set mailman [new_CkMailMan]

#  Configure the POP3 server connection.
CkMailMan_put_MailHost $mailman "pop.example.com"
CkMailMan_put_MailPort $mailman 995
CkMailMan_put_PopSsl $mailman 1
CkMailMan_put_PopUsername $mailman "user@example.com"
CkMailMan_put_PopPassword $mailman "myPassword"

#  Explicitly begin a POP3 session.

set success [CkMailMan_Pop3BeginSession $mailman]
if {$success == 0} then {
    puts [CkMailMan_lastErrorText $mailman]
    delete_CkMailMan $mailman
    exit
}

#  ... perform mailbox operations here, such as fetching or marking messages for deletion ...

#  End the POP3 session (sends QUIT), committing any pending deletions.
set success [CkMailMan_Pop3EndSession $mailman]
if {$success == 0} then {
    puts [CkMailMan_lastErrorText $mailman]
    delete_CkMailMan $mailman
    exit
}

puts "POP3 session ended."

delete_CkMailMan $mailman