Swift Requires Chilkat v11.0.0+
Swift
Transition from MailMan.MxLookupAll to the Chilkat DNS class
Provides instructions for replacing deprecated MxLookupAll method calls with the Chilkat Dns class. The code below uses the replacement API without constructing the deprecated returned array.Chilkat Swift Downloads
func chilkatTest() {
var success: Bool = false
var emailAddr: String? = "joe@example.com"
// Replace the deprecated MxLookupAll method using the Chilkat DNS class
let dns = CkoDns()!
let json = CkoJsonObject()!
// This gets all MX domains for an email address. (Typically one domain.)
// The preferred domain will be at index 0 (see below).
success = dns.query(recordType: "MX", domain: emailAddr, answer: json)
if success == false {
print("\(dns.lastErrorText!)")
return
}
var i: Int = 0
var count_i: Int = json.size(ofArray: "answer.mx").intValue
while i < count_i {
json.i = i
var domain: String? = json.string(of: "answer.mx[i].domain")
print("\(domain!)")
i = i + 1
}
}