Fix crash when no MX record is found

This commit is contained in:
Girish Ramakrishnan
2017-02-02 11:14:10 -08:00
parent 651af185c8
commit ce2cd00fbf

View File

@@ -212,6 +212,9 @@ function getEmailDnsRecords(callback) {
if (error && error.code === 'ENOTFOUND') return callback(null); // not setup
if (error) return callback(error);
// ensure this is an array resolveMx() returns undefined if no records are found
mxRecords = mxRecords || [];
records.mx.status = mxRecords.length == 1 && mxRecords[0].exchange === config.mailFqdn();
records.mx.value = mxRecords.map(function (r) { return r.priority + ' ' + r.exchange; }).join(' ');