Tcl
Tcl
Send a Raw POP3 Command
See more POP3 Examples
Demonstrates the Chilkat MailMan.Pop3SendRawCommand method, which sends a raw command to the POP3 server and returns the server's response. The second argument specifies the charset to use if the command contains non-US-ASCII characters. This example sends the POP3 STAT command within an open session.
Background: POP3 is a simple line-based text protocol — the client sends short commands like
STAT, LIST, UIDL, or RETR and the server replies with +OK or -ERR. This method is an escape hatch for issuing a command Chilkat doesn't wrap directly, or a server-specific extension. Note that the session must already be open, since a raw command assumes an authenticated connection.Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
# Demonstrates the MailMan.Pop3SendRawCommand method, which sends a raw command to the POP3
# server and returns the server's response. The second argument is the charset used if the
# command contains non-US-ASCII characters.
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"
set success [CkMailMan_Pop3BeginSession $mailman]
if {$success == 0} then {
puts [CkMailMan_lastErrorText $mailman]
delete_CkMailMan $mailman
exit
}
# Send the raw POP3 STAT command, which returns the message count and maildrop size.
set response [CkMailMan_pop3SendRawCommand $mailman "STAT" "us-ascii"]
if {[CkMailMan_get_LastMethodSuccess $mailman] == 0} then {
puts [CkMailMan_lastErrorText $mailman]
delete_CkMailMan $mailman
exit
}
puts "STAT response: $response"
set success [CkMailMan_Pop3EndSession $mailman]
if {$success == 0} then {
puts [CkMailMan_lastErrorText $mailman]
delete_CkMailMan $mailman
exit
}
delete_CkMailMan $mailman