C++
C++
Transition from MailMan.MxLookupAll to the Chilkat DNS class
Provides instructions for replacing deprecated MxLookupAll method calls with the Chilkat Dns class.Chilkat C++ Downloads
#include <CkMailMan.h>
#include <CkStringArray.h>
#include <CkDns.h>
#include <CkJsonObject.h>
void ChilkatSample(void)
{
bool success = false;
CkMailMan mailman;
// ...
// ...
const char *emailAddr = "joe@example.com";
// ------------------------------------------------------------------------
// The MxLookupAll method is deprecated:
CkStringArray *sa = mailman.MxLookupAll(emailAddr);
if (mailman.get_LastMethodSuccess() == false) {
std::cout << mailman.lastErrorText() << "\r\n";
return;
}
// ...
// ...
delete sa;
// ------------------------------------------------------------------------
// Do the equivalent using the Chilkat DNS class
CkDns dns;
CkJsonObject json;
// 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("MX",emailAddr,json);
if (success == false) {
std::cout << dns.lastErrorText() << "\r\n";
return;
}
int i = 0;
int count_i = json.SizeOfArray("answer.mx");
while (i < count_i) {
json.put_I(i);
const char *domain = json.stringOf("answer.mx[i].domain");
std::cout << domain << "\r\n";
i = i + 1;
}
}