@@ -117,6 +117,23 @@ export type GetDomainDNSRecordsOutput =
117
117
optimal : string ;
118
118
acceptable : string ;
119
119
} ;
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
+ } ;
120
137
}
121
138
| { error : string } ;
122
139
@@ -166,6 +183,23 @@ export async function getDomainDNSRecords(
166
183
name : '' ,
167
184
optimal : '' ,
168
185
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
+ }
169
203
}
170
204
} ;
171
205
@@ -317,7 +351,7 @@ export async function getDomainDNSRecords(
317
351
}
318
352
records . mx . name = domainInfo . name ;
319
353
records . mx . priority = 1 ;
320
- records . mx . value = `mx. ${ postalServerUrl } ` ;
354
+ records . mx . value = `${ postalServerUrl } ` ;
321
355
records . mx . valid = true ;
322
356
323
357
if ( domainInfo . mxStatus !== 'OK' || forceReverify ) {
@@ -360,6 +394,40 @@ export async function getDomainDNSRecords(
360
394
records . dmarc . name = '_dmarc' ;
361
395
records . dmarc . optimal = buildDmarcRecord ( { p : 'reject' } ) ;
362
396
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:[email protected] ` ;
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:[email protected] ' )
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
+
363
431
return records ;
364
432
}
365
433
0 commit comments