@@ -117,6 +117,23 @@ export type GetDomainDNSRecordsOutput =
117117 optimal : string ;
118118 acceptable : string ;
119119 } ;
120+ mtaSts : {
121+ dns : {
122+ valid : boolean ;
123+ name : string ;
124+ value : string ;
125+ } ;
126+ tls : {
127+ valid : boolean ;
128+ name : string ;
129+ value : string ;
130+ } ;
131+ policy : {
132+ valid : boolean ;
133+ name : string ;
134+ value : string ;
135+ } ;
136+ } ;
120137 }
121138 | { error : string } ;
122139
@@ -166,6 +183,23 @@ export async function getDomainDNSRecords(
166183 name : '' ,
167184 optimal : '' ,
168185 acceptable : ''
186+ } ,
187+ mtaSts : {
188+ dns : {
189+ valid : false ,
190+ name : '' ,
191+ value : ''
192+ } ,
193+ tls : {
194+ valid : false ,
195+ name : '' ,
196+ value : ''
197+ } ,
198+ policy : {
199+ valid : false ,
200+ name : '' ,
201+ value : ''
202+ }
169203 }
170204 } ;
171205
@@ -317,7 +351,7 @@ export async function getDomainDNSRecords(
317351 }
318352 records . mx . name = domainInfo . name ;
319353 records . mx . priority = 1 ;
320- records . mx . value = `mx. ${ postalServerUrl } ` ;
354+ records . mx . value = `${ postalServerUrl } ` ;
321355 records . mx . valid = true ;
322356
323357 if ( domainInfo . mxStatus !== 'OK' || forceReverify ) {
@@ -360,6 +394,40 @@ export async function getDomainDNSRecords(
360394 records . dmarc . name = '_dmarc' ;
361395 records . dmarc . optimal = buildDmarcRecord ( { p : 'reject' } ) ;
362396 records . dmarc . acceptable = buildDmarcRecord ( { p : 'quarantine' } ) ;
397+
398+ const mtaStsDnsRecord = await lookupTXT ( `_mta-sts.${ domainInfo . name } ` ) ;
399+ records . mtaSts . dns . name = '_mta-sts' ;
400+ records . mtaSts . dns . value = `v=STSv1; id=${ Date . now ( ) } ` ;
401+ if ( mtaStsDnsRecord . success && mtaStsDnsRecord . data . length > 0 ) {
402+ records . mtaSts . dns . valid =
403+ mtaStsDnsRecord . data . filter (
404+ ( _ ) => _ . startsWith ( 'v=STSv1;' ) && _ . includes ( 'id=' )
405+ ) . length === 1 ;
406+ }
407+
408+ const mtaStsTlsRecord = await lookupTXT ( `_smtp._tls.${ domainInfo . name } ` ) ;
409+ records . mtaSts . tls . name = '_smtp._tls' ;
410+ records . mtaSts . tls . value = `v=TLSRPTv1; rua=mailto:tlsrpt@reports.uninbox.com` ;
411+ if ( mtaStsTlsRecord . success && mtaStsTlsRecord . data . length > 0 ) {
412+ records . mtaSts . tls . valid =
413+ mtaStsTlsRecord . data . filter (
414+ ( _ ) =>
415+ _ . startsWith ( 'v=TLSRPTv1;' ) &&
416+ _ . includes ( 'rua=' ) &&
417+ _ . includes ( 'mailto:tlsrpt@reports.uninbox.com' )
418+ ) . length === 1 ;
419+ }
420+
421+ const mtaStsPolicyRecord = await lookupCNAME ( `mta-sts.${ domainInfo . name } ` ) ;
422+ records . mtaSts . policy . name = 'mta-sts' ;
423+ records . mtaSts . policy . value = `mta-sts.${ postalServerUrl } ` ;
424+ if (
425+ mtaStsPolicyRecord . success &&
426+ mtaStsPolicyRecord . data . includes ( records . mtaSts . policy . value )
427+ ) {
428+ records . mtaSts . policy . valid = true ;
429+ }
430+
363431 return records ;
364432}
365433
0 commit comments