Sample code for 30+ languages & platforms
PureBasic

Explicitly Connect to the POP3 Server

See more POP3 Examples

Demonstrates the Chilkat MailMan.Pop3Connect method, which explicitly connects to the POP3 server. If SSL/TLS is required by the current property settings, the secure TLS channel is established as part of connecting. This example opens the connection.

Background: Pop3Connect performs just the connect (and TLS handshake) step, without authenticating. Separating it from Pop3Authenticate gives explicit control over the session lifecycle and makes it easy to tell a connection failure apart from a login failure. For routine mailbox operations you don't need it — methods like CheckMail connect automatically.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkMailMan.pb"

Procedure ChilkatExample()

    success.i = 0

    ;  Demonstrates the MailMan.Pop3Connect method, which explicitly connects to the POP3 server.
    ;  If SSL/TLS is required by the current property settings, the secure channel is established
    ;  as part of connecting.

    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)

    ;  Explicitly connect to the POP3 server (does not authenticate).

    success = CkMailMan::ckPop3Connect(mailman)
    If success = 0
        Debug CkMailMan::ckLastErrorText(mailman)
        CkMailMan::ckDispose(mailman)
        ProcedureReturn
    EndIf

    Debug "Connected to the POP3 server."


    CkMailMan::ckDispose(mailman)


    ProcedureReturn
EndProcedure