#!/bin/sh
set -euC
# nfsn-dns-dmarc DOMAIN NAME EMAIL_NAME POLICY
# nfsn-dns-dmarc "example.com" "" "" "none"
# nfsn-dns-dmarc "example.com" "" "" "quarantine"
# nfsn-dns-dmarc "example.com" "" "" "reject"
# Arguments.
domain="$1" ; shift
name="$1" ; shift
email_name="${1:-"postmaster"}" ; shift
policy="$1" ; shift
# Process.
name="_dmarc${name:+".$name"}"
data="$(
printf "%s" \
"v=DMARC1; " \
"p=$policy; " \
"sp=$policy; " \
"pct=100; " \
"rua=mailto:$email_name@$domain"
)"
# Update.
nfsn-dns-update "$domain" "$name" "TXT" '' "$data"
|