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.
Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loMailman
LOCAL lnCount
lnSuccess = 0
* Assumes Chilkat is unlocked. See Global Unlock Sample.
loMailman = CreateObject('Chilkat.MailMan')
* Use a provider that explicitly supports POP STLS on port 110.
* Gmail documents implicit TLS on pop.gmail.com:995 instead.
loMailman.MailHost = "pop.example.com"
loMailman.MailPort = 110
loMailman.PopSsl = 0
loMailman.Pop3Stls = 1
loMailman.Pop3StlsIfPossible = 0
loMailman.RequireSslCertVerify = 1
loMailman.PopUsername = "user@example.com"
loMailman.PopPassword = "YOUR_PROVIDER_ISSUED_PASSWORD"
lnSuccess = loMailman.Pop3BeginSession()
IF (lnSuccess <> 1) THEN
loMailman.Pop3EndSessionNoQuit()
? "POP connection or authentication failed. STLS must succeed before credentials are sent."
RELEASE loMailman
CANCEL
ENDIF
lnCount = loMailman.CheckMail()
IF (lnCount < 0) THEN
loMailman.Pop3EndSessionNoQuit()
? "Could not obtain the POP message count."
RELEASE loMailman
CANCEL
ENDIF
? "Available POP messages: " + STR(lnCount)
lnSuccess = loMailman.Pop3EndSession()
IF (lnSuccess <> 1) THEN
? "The count was obtained, but closing the POP session failed."
ENDIF
RELEASE loMailman