PureBasic
PureBasic
Authenticate with the POP3 Server
See more POP3 Examples
Demonstrates the Chilkat MailMan.Pop3Authenticate method, which authenticates with the POP3 server using the current POP3 property settings, such as PopUsername and PopPassword. It is typically called after Pop3Connect. This example connects and then authenticates.
Background: POP3 authentication is the step, after connecting, where the client identifies itself — classically with the
USER and PASS commands, or a more secure mechanism. Calling Pop3Connect and Pop3Authenticate as distinct steps lets you determine precisely which phase fails, and lets you hold an authenticated session open to perform several mailbox operations before ending it with Pop3EndSession.Chilkat PureBasic Downloads
IncludeFile "CkMailMan.pb"
Procedure ChilkatExample()
success.i = 0
; Demonstrates the MailMan.Pop3Authenticate method, which authenticates with the POP3 server
; using the current POP3 property settings (such as PopUsername and PopPassword). It is
; typically called after Pop3Connect.
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")
; Connect first, then authenticate.
success = CkMailMan::ckPop3Connect(mailman)
If success = 0
Debug CkMailMan::ckLastErrorText(mailman)
CkMailMan::ckDispose(mailman)
ProcedureReturn
EndIf
success = CkMailMan::ckPop3Authenticate(mailman)
If success = 0
Debug CkMailMan::ckLastErrorText(mailman)
CkMailMan::ckDispose(mailman)
ProcedureReturn
EndIf
Debug "Authenticated with the POP3 server."
CkMailMan::ckDispose(mailman)
ProcedureReturn
EndProcedure