PureBasic
PureBasic
Transition from MailMan.MxLookupAll to the Chilkat DNS class
Provides instructions for replacing deprecated MxLookupAll method calls with the Chilkat Dns class.Chilkat PureBasic Downloads
IncludeFile "CkMailMan.pb"
IncludeFile "CkJsonObject.pb"
IncludeFile "CkDns.pb"
IncludeFile "CkStringArray.pb"
Procedure ChilkatExample()
success.i = 0
mailman.i = CkMailMan::ckCreate()
If mailman.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; ...
; ...
emailAddr.s = "joe@example.com"
; ------------------------------------------------------------------------
; The MxLookupAll method is deprecated:
sa.i = CkMailMan::ckMxLookupAll(mailman,emailAddr)
If CkMailMan::ckLastMethodSuccess(mailman) = 0
Debug CkMailMan::ckLastErrorText(mailman)
CkMailMan::ckDispose(mailman)
ProcedureReturn
EndIf
; ...
; ...
CkStringArray::ckDispose(sa)
; ------------------------------------------------------------------------
; Do the equivalent using the Chilkat DNS class
dns.i = CkDns::ckCreate()
If dns.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; This gets all MX domains for an email address. (Typically one domain.)
; The preferred domain will be at index 0 (see below).
success = CkDns::ckQuery(dns,"MX",emailAddr,json)
If success = 0
Debug CkDns::ckLastErrorText(dns)
CkMailMan::ckDispose(mailman)
CkDns::ckDispose(dns)
CkJsonObject::ckDispose(json)
ProcedureReturn
EndIf
i.i = 0
count_i.i = CkJsonObject::ckSizeOfArray(json,"answer.mx")
While i < count_i
CkJsonObject::setCkI(json, i)
domain.s = CkJsonObject::ckStringOf(json,"answer.mx[i].domain")
Debug domain
i = i + 1
Wend
CkMailMan::ckDispose(mailman)
CkDns::ckDispose(dns)
CkJsonObject::ckDispose(json)
ProcedureReturn
EndProcedure