(Swift) Connecting to GMAIL using IMAP
Demonstrates how to connect to GMAIL using IMAP.
func chilkatTest() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let imap = CkoImap()!
// Turn on session logging:
imap.keepSessionLog = true
// Connect to GMail
// Use TLS
imap.ssl = true
imap.port = 993
var success: Bool = imap.connect("imap.gmail.com")
if success != true {
print("\(imap.lastErrorText!)")
return
}
// Login
// Your login is typically your GMail email address.
success = imap.login("username@gmail.com", password: "myPassword")
if success != true {
print("\(imap.lastErrorText!)")
return
}
// Select an IMAP mailbox
success = imap.selectMailbox("Inbox")
if success != true {
print("\(imap.lastErrorText!)")
return
}
// Show the session log.
print("\(imap.sessionLog!)")
// Disconnect from the IMAP server.
success = imap.disconnect()
}
|