(Swift 3,4,5...) POP3 STARTTLS
Demonstrates how to do POP3 STARTTLS.
func chilkatTest() {
// 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.
let mailman = CkoMailMan()!
// Set the POP3 server's hostname
mailman.mailHost = "pop.gmail.com"
// Set the POP3 login/password.
mailman.popUsername = "****@gmail.com"
mailman.popPassword = "****"
// Indicate that we want TLS/SSL. Also, set the port to 995:
mailman.mailPort = 995
mailman.popSsl = true
var bundle: CkoEmailBundle? = mailman.copyMail()
if mailman.lastMethodSuccess == false {
print("\(mailman.lastErrorText!)")
return
}
var i: Int = 0
var email: CkoEmail?
while i < bundle!.messageCount.intValue {
email = bundle!.getEmail(i)
// Display the From email address and the subject.
print("From: \(email!.from!)")
print("Subject: \(email!.subject!)")
email = nil
i = i + 1
}
bundle = nil
}
|