Sample code for 30+ languages & platforms
DataFlex

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 DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoMailman
    String sTemp1

    Move False To iSuccess

    //  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.

    Get Create (RefClass(cComChilkatMailMan)) To hoMailman
    If (Not(IsComObjectCreated(hoMailman))) Begin
        Send CreateComObject of hoMailman
    End

    //  Configure the POP3 server connection.
    Set ComMailHost Of hoMailman To "pop.example.com"
    Set ComMailPort Of hoMailman To 995
    Set ComPopSsl Of hoMailman To True

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

    Get ComPop3Connect Of hoMailman To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoMailman To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "Connected to the POP3 server."


End_Procedure