Lua Requires Chilkat v11.0.0+
Lua
POP3 STARTTLS
Demonstrates how to do POP3 STARTTLS.Chilkat Lua Downloads
-- In the following call to loadlib, change the path (./chilkat.dll) to the relative or absolute directory where the chilkat.dll, chilkat.so, or chilkat.dylib is located.
chilkat = assert(package.loadlib("./chilkat.dll", "luaopen_chilkat"))()
print(chilkat._VERSION)
local success = false
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
-- The mailman object is used for receiving (POP3)
-- and sending (SMTP) email.
local mailman = chilkat.newMailMan{}
-- Set the POP3 server's hostname
mailman:setMailHost("pop.gmail.com")
-- Set the POP3 login/password.
mailman:setPopUsername("****@gmail.com")
mailman:setPopPassword("****")
-- Indicate that we want TLS/SSL. Also, set the port to 995:
mailman:setMailPort(995)
mailman:setPopSsl(true)
local bundle = chilkat.newEmailBundle{}
local keepOnServer = true
local headersOnly = false
-- Irrelevent because we are NOT downloading headers-only
local numBodyLines = 0
success = mailman:FetchAll(keepOnServer,headersOnly,numBodyLines,bundle)
if success == false then
print(mailman:LastErrorText())
end
local email = chilkat.newEmail{}
local i = 0
while i < bundle:MessageCount() do
bundle:EmailAt(i,email)
-- Display the From email address and the subject.
print("From: ", email:From())
print("Subject: ", email:Subject())
i = i + 1
end