PureBasic
PureBasic
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 PureBasic Downloads
IncludeFile "CkMailMan.pb"
Procedure ChilkatExample()
success.i = 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.
mailman.i = CkMailMan::ckCreate()
If mailman.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Configure the POP3 server connection.
CkMailMan::setCkMailHost(mailman, "pop.example.com")
CkMailMan::setCkMailPort(mailman, 995)
CkMailMan::setCkPopSsl(mailman, 1)
CkMailMan::setCkPopUsername(mailman, "user@example.com")
CkMailMan::setCkPopPassword(mailman, "myPassword")
success = CkMailMan::ckPop3BeginSession(mailman)
If success = 0
Debug CkMailMan::ckLastErrorText(mailman)
CkMailMan::ckDispose(mailman)
ProcedureReturn
EndIf
; Send the raw POP3 STAT command, which returns the message count and maildrop size.
response.s = CkMailMan::ckPop3SendRawCommand(mailman,"STAT","us-ascii")
If CkMailMan::ckLastMethodSuccess(mailman) = 0
Debug CkMailMan::ckLastErrorText(mailman)
CkMailMan::ckDispose(mailman)
ProcedureReturn
EndIf
Debug "STAT response: " + response
success = CkMailMan::ckPop3EndSession(mailman)
If success = 0
Debug CkMailMan::ckLastErrorText(mailman)
CkMailMan::ckDispose(mailman)
ProcedureReturn
EndIf
CkMailMan::ckDispose(mailman)
ProcedureReturn
EndProcedure