Node.js
Node.js
Transition from MailMan.MxLookupAll to the Chilkat DNS class
Provides instructions for replacing deprecated MxLookupAll method calls with the Chilkat Dns class.Chilkat Node.js Downloads
NODEJS_PRELUDE
function chilkatExample() {
var success = false;
var mailman = new chilkat.MailMan();
// ...
// ...
var emailAddr = "joe@example.com";
// ------------------------------------------------------------------------
// The MxLookupAll method is deprecated:
// sa: StringArray
var sa = mailman.MxLookupAll(emailAddr);
if (mailman.LastMethodSuccess == false) {
console.log(mailman.LastErrorText);
return;
}
// ...
// ...
// ------------------------------------------------------------------------
// Do the equivalent using the Chilkat DNS class
var dns = new chilkat.Dns();
var json = new chilkat.JsonObject();
// 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) {
console.log(dns.LastErrorText);
return;
}
var i = 0;
var count_i = json.SizeOfArray("answer.mx");
while (i < count_i) {
json.I = i;
var domain = json.StringOf("answer.mx[i].domain");
console.log(domain);
i = i+1;
}
}
chilkatExample();