# Build a DMARC record

Compose the TXT value for _dmarc.<domain> from a policy and an optional report address.

Canonical: https://1loc.dev/email/build-a-dmarc-record/
Version: 1.0.0
Runtime: JavaScript · Node.js 22 / modern browsers
Verification: Local fixtures; no external services
Updated: 2026-10-28

## Implementation

```javascript
function dmarcRecord({ policy, rua }) { return ['v=DMARC1', `p=${policy}`, ...(rua ? [`rua=${rua}`] : [])].join('; '); }
```

## Input

```json
{
  "policy": "none",
  "rua": "mailto:dmarc-reports@your-verified-domain.example"
}
```

## Expected output

```json
"v=DMARC1; p=none; rua=mailto:dmarc-reports@your-verified-domain.example"
```

## Edge case

Input:
```json
{
  "policy": "reject"
}
```
Output:
```json
"v=DMARC1; p=reject"
```

## Limits

- Publish the value as a TXT record at _dmarc.<your-domain>; v=DMARC1 must come first (RFC 7489). Start with p=none and aggregate reports, then move to quarantine and reject once SPF or DKIM alignment holds.
- Oveyon’s POST /v1/domains returns the SPF, DKIM and DMARC records to publish for a sending domain; prefer those values when they are available.

The lab validates types and size before calling this function. Add equivalent validation at your own trust boundary.

## Source and license

Author: Oveyon, written for this edition; not part of the original 1loc collection.
Copyright (c) 2026 Oveyon
License: MIT — https://1loc.dev/licenses/
Maintainer: Oveyon
