more robust detection and injection of SPF record

Fixes #210
This commit is contained in:
Girish Ramakrishnan
2017-02-15 18:27:37 -08:00
parent c6d2c39ff7
commit d8273719d2
3 changed files with 18 additions and 12 deletions

View File

@@ -182,6 +182,7 @@ function getEmailDnsRecords(callback) {
status: false
};
// https://agari.zendesk.com/hc/en-us/articles/202952749-How-long-can-my-SPF-record-be-
dns.resolve(records.spf.domain, records.spf.type, function (error, txtRecords) {
if (error && error.code === 'ENOTFOUND') return callback(null); // not setup
if (error) return callback(error);
@@ -190,9 +191,9 @@ function getEmailDnsRecords(callback) {
var i;
for (i = 0; i < txtRecords.length; i++) {
if (txtRecords[i].join(' ').indexOf('v=spf1 ') !== 0) continue; // not SPF
records.spf.value = txtRecords[i].join(' ');
records.spf.status = records.spf.value.indexOf(' a:' + config.adminFqdn() + ' ') !== -1;
if (txtRecords[i].join('').indexOf('v=spf1 ') !== 0) continue; // not SPF
records.spf.value = txtRecords[i].join('');
records.spf.status = records.spf.value.indexOf(' a:' + config.adminFqdn()) !== -1;
break;
}