Node.js
Node.js
Transition from MailMan.MxLookup to Dns.Query
Provides instructions for replacing deprecated MxLookup 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 MxLookup method is deprecated:
var domain = mailman.MxLookup(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;
domain = json.StringOf("answer.mx[i].domain");
console.log(domain);
i = i+1;
}
}
chilkatExample();