Sample code for 30+ languages & platforms
SQL Server

Verify POP3 Login (Connect and Authenticate)

See more POP3 Examples

Demonstrates the Chilkat MailMan.VerifyPopLogin method, which tests whether Chilkat can connect to the configured POP3 server and successfully log in using the current POP3 authentication settings. This example configures the POP3 host and credentials and verifies login.

Background: POP3 login is the USER/PASS (or APOP/SASL) exchange that follows connecting. VerifyPopLogin performs the full round trip — connect, TLS, and authenticate — making it the go-to preflight check for validating a mailbox's credentials. A false result after VerifyPopConnection succeeds isolates the problem to the username or password.

Chilkat SQL Server Downloads

SQL Server
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @success int
    SELECT @success = 0

    --  Demonstrates the MailMan.VerifyPopLogin method, which tests whether Chilkat can connect to
    --  the configured POP3 server and successfully log in using the current POP3 authentication
    --  settings.

    DECLARE @mailman int
    EXEC @hr = sp_OACreate 'Chilkat.MailMan', @mailman OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    --  Configure the POP3 server connection.
    EXEC sp_OASetProperty @mailman, 'MailHost', 'pop.example.com'
    EXEC sp_OASetProperty @mailman, 'MailPort', 995
    EXEC sp_OASetProperty @mailman, 'PopSsl', 1
    EXEC sp_OASetProperty @mailman, 'PopUsername', 'user@example.com'
    EXEC sp_OASetProperty @mailman, 'PopPassword', 'myPassword'

    --  Test both connectivity and login.
    DECLARE @loggedIn int
    EXEC sp_OAMethod @mailman, 'VerifyPopLogin', @loggedIn OUT

    IF @loggedIn = 1
      BEGIN

        PRINT 'Successfully connected and logged in to the POP3 server.'
      END
    ELSE
      BEGIN

        PRINT 'POP3 connect or login failed.'
      END

    EXEC @hr = sp_OADestroy @mailman


END
GO