Sample code for 30+ languages & platforms
PowerBuilder Requires Chilkat v11.0.0+

POP3: Require an STLS Upgrade Before Authentication

Connect to a provider that supports POP STLS on port 110, require the TLS upgrade, then authenticate and obtain a message count. Set PopSsl=false, Pop3Stls=true, and enable certificate verification. Replace the generic host and credentials with settings issued by that provider. Use the provider's OAuth or app-password policy where applicable.

The former example was mislabeled: it connected to Gmail on port 995 using implicit TLS and never performed STLS. Gmail's documented POP configuration remains pop.gmail.com:995 with PopSsl=true; use Gmail POP OAuth2 for that connection.

The required STLS setting fails if the upgrade is unavailable. An opportunistic setting can leave a connection unencrypted and is not used here.

See the Gmail SMTP, IMAP, and POP3 guide for current authentication choices and Gmail-specific examples.

Reference documentation

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
long li_Success
oleobject loo_Mailman
long li_Count

li_Success = 0

//  Assumes Chilkat is unlocked. See Global Unlock Sample.

loo_Mailman = create oleobject
li_rc = loo_Mailman.ConnectToNewObject("Chilkat.MailMan")
if li_rc < 0 then
    destroy loo_Mailman
    MessageBox("Error","Connecting to COM object failed")
    return
end if
//  Use a provider that explicitly supports POP STLS on port 110.
//  Gmail documents implicit TLS on pop.gmail.com:995 instead.
loo_Mailman.MailHost = "pop.example.com"
loo_Mailman.MailPort = 110
loo_Mailman.PopSsl = 0
loo_Mailman.Pop3Stls = 1
loo_Mailman.Pop3StlsIfPossible = 0
loo_Mailman.RequireSslCertVerify = 1
loo_Mailman.PopUsername = "user@example.com"
loo_Mailman.PopPassword = "YOUR_PROVIDER_ISSUED_PASSWORD"
li_Success = loo_Mailman.Pop3BeginSession()
if li_Success <> 1 then
    loo_Mailman.Pop3EndSessionNoQuit()
    Write-Debug "POP connection or authentication failed. STLS must succeed before credentials are sent."
    destroy loo_Mailman
    return
end if

li_Count = loo_Mailman.CheckMail()
if li_Count < 0 then
    loo_Mailman.Pop3EndSessionNoQuit()
    Write-Debug "Could not obtain the POP message count."
    destroy loo_Mailman
    return
end if

Write-Debug "Available POP messages: " + string(li_Count)
li_Success = loo_Mailman.Pop3EndSession()
if li_Success <> 1 then
    Write-Debug "The count was obtained, but closing the POP session failed."
end if



destroy loo_Mailman