Sample code for 30+ languages & platforms
Unicode C

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 Unicode C Downloads

Unicode C
#include <C_CkMailManW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkMailManW mailman;

    success = FALSE;

    //  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 = CkMailManW_Create();

    //  Configure the POP3 server connection.
    CkMailManW_putMailHost(mailman,L"pop.example.com");
    CkMailManW_putMailPort(mailman,995);
    CkMailManW_putPopSsl(mailman,TRUE);

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

    success = CkMailManW_Pop3Connect(mailman);
    if (success == FALSE) {
        wprintf(L"%s\n",CkMailManW_lastErrorText(mailman));
        CkMailManW_Dispose(mailman);
        return;
    }

    wprintf(L"Connected to the POP3 server.\n");


    CkMailManW_Dispose(mailman);

    }