Sample code for 30+ languages & platforms
Swift

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

Swift

func chilkatTest() {
    var success: Bool = false

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

    let mailman = CkoMailMan()!

    //  Configure the POP3 server connection.
    mailman.mailHost = "pop.example.com"
    mailman.mailPort = 995
    mailman.popSsl = true
    mailman.popUsername = "user@example.com"
    mailman.popPassword = "myPassword"

    //  Connect first, then authenticate.

    success = mailman.pop3Connect()
    if success == false {
        print("\(mailman.lastErrorText!)")
        return
    }

    success = mailman.pop3Authenticate()
    if success == false {
        print("\(mailman.lastErrorText!)")
        return
    }

    print("Authenticated with the POP3 server.")

}