Sample code for 30+ languages & platforms
VBScript 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 VBScript Downloads

VBScript
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)

success = 0

'  Assumes Chilkat is unlocked. See Global Unlock Sample.

set mailman = CreateObject("Chilkat.MailMan")
'  Use a provider that explicitly supports POP STLS on port 110.
'  Gmail documents implicit TLS on pop.gmail.com:995 instead.
mailman.MailHost = "pop.example.com"
mailman.MailPort = 110
mailman.PopSsl = 0
mailman.Pop3Stls = 1
mailman.Pop3StlsIfPossible = 0
mailman.RequireSslCertVerify = 1
mailman.PopUsername = "user@example.com"
mailman.PopPassword = "YOUR_PROVIDER_ISSUED_PASSWORD"
success = mailman.Pop3BeginSession()
If (success <> 1) Then
    success = mailman.Pop3EndSessionNoQuit()
    outFile.WriteLine("POP connection or authentication failed. STLS must succeed before credentials are sent.")
    WScript.Quit
End If

count = mailman.CheckMail()
If (count < 0) Then
    success = mailman.Pop3EndSessionNoQuit()
    outFile.WriteLine("Could not obtain the POP message count.")
    WScript.Quit
End If

outFile.WriteLine("Available POP messages: " & count)
success = mailman.Pop3EndSession()
If (success <> 1) Then
    outFile.WriteLine("The count was obtained, but closing the POP session failed.")
End If


outFile.Close