chore: complete the mail domain setup
This commit is contained in:
@@ -20,8 +20,9 @@ export class DnsService {
|
||||
private readonly logger = new Logger(DnsService.name);
|
||||
|
||||
private readonly mailServerDomain: string = "mail.danakcorp.com";
|
||||
private readonly spfRecord: string = `v=spf1 include:${this.mailServerDomain} ~all`;
|
||||
private readonly dmarcRecord: string = `v=DMARC1; p=quarantine; rua=mailto:dmarc@${this.mailServerDomain}; ruf=mailto:dmarc@${this.mailServerDomain}`;
|
||||
private readonly serverDomain: string = "danakcorp.com";
|
||||
private readonly spfRecord: string = `v=spf1 mx include:${this.serverDomain} ~all`;
|
||||
// private readonly dmarcRecord: string = `v=DMARC1; p=quarantine; rua=mailto:dmarc@${this.serverDomain}; ruf=mailto:dmarc@${this.serverDomain}`;
|
||||
|
||||
private readonly resolveTxt = promisify(dns.resolveTxt);
|
||||
private readonly resolveCname = promisify(dns.resolveCname);
|
||||
@@ -107,10 +108,11 @@ export class DnsService {
|
||||
});
|
||||
|
||||
// DMARC Record
|
||||
const dmarcRecord = `v=DMARC1; p=quarantine; rua=mailto:dmarc@${domain.name}; ruf=mailto:dmarc@${domain.name}`;
|
||||
requiredRecords.push({
|
||||
name: `_dmarc.${domain.name}`,
|
||||
type: DNSRecordType.DMARC,
|
||||
value: this.dmarcRecord,
|
||||
value: dmarcRecord,
|
||||
isRequired: true,
|
||||
description: "DMARC policy record",
|
||||
});
|
||||
@@ -269,7 +271,11 @@ export class DnsService {
|
||||
const txtRecords = await this.resolveTxt(dnsRecord.name);
|
||||
const flatRecords = txtRecords.flat();
|
||||
|
||||
return flatRecords.some((record) => record.includes(dnsRecord.value) || record === dnsRecord.value);
|
||||
// Join all TXT record parts together (handles multi-part TXT records like DKIM)
|
||||
const joinedRecord = flatRecords.join("");
|
||||
|
||||
// Check if the expected value matches either the joined record or any individual part
|
||||
return joinedRecord === dnsRecord.value || flatRecords.some((record) => record.includes(dnsRecord.value) || record === dnsRecord.value);
|
||||
} catch (error) {
|
||||
this.logger.debug(`TXT record verification failed for ${dnsRecord.name}:`, error instanceof Error ? error.message : "Unknown error");
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user