GoMilterD Operator Manual
GoMilterD is a fast, modular Milter daemon for Postfix and Sendmail written in Go. It consolidates email authentication (SPF, DKIM, DMARC, ARC, BIMI, IPRev), DNSBL lookups, greylisting, ClamAV scanning, and zero-PII UDP telemetry into a single binary with one YAML configuration.
New to GoMilterD? Start with the Quick Start Guide.
Licensed under the GNU Affero General Public License v3.0 (AGPLv3).
© 2026 Threat InSites Inc DBA EmailAbuse.Net
Core Architecture & Global Configuration
Modules capable of asynchronous I/O (such as IPRev, SPF, DNSBL, and ClamAV) begin their work as soon as the relevant SMTP phase occurs and synchronize at the configured evaluation boundary (typically End-of-Message).
Global settings are defined at the root of gomilterd.yaml and cascade down to
individual modules unless overridden locally. Modules that inherit the global
resolvers and timeout_ms share a single compiled resolver pool.
# Listener Configuration
network: "unix" # "unix" or "tcp"
address: "/var/run/gomilterd/gomilterd.sock" # Socket path or "host:port"
socket_mode: "0660" # Octal permissions for Unix sockets
max_connections: 1024
# Authentication-Results Identity (Required)
authserv_id: "mx.example.com"
# Session Direction Detection ("auto", "inbound", or "outbound")
mode: "auto"
originating_daemons:
- "ORIGINATING"
- "MSA"
originating_ports:
- "587"
- "465"
# Global DNS & Network Defaults
resolvers:
- "127.0.0.1:53"
timeout_ms: 3000
trusted_networks:
- "127.0.0.0/8"
- "::1/128"
- "10.0.0.0/8"
# Startup Validation
pre_flight_check: true
pre_flight_verbose: false
| Parameter | Type | Default | Description |
|---|---|---|---|
network |
string | — | Socket transport protocol (unix or tcp). |
address |
string | — | File path for Unix domain sockets or IP:Port for TCP listeners. |
socket_mode |
string | "0660" |
Octal file permissions applied to Unix domain sockets (e.g., "0660" or "0666"). |
max_connections |
int | 0 |
Maximum concurrent milter sessions (0 = unlimited). |
authserv_id |
string | (Required) | Hostname stamped into Authentication-Results, ARC-Authentication-Results, and DNSBL-Results headers. |
mode |
string | "auto" |
Controls session direction ("auto", "inbound", or "outbound"). In "auto" mode, a session is treated as outbound if the client is SMTP-authenticated ({auth_type} or {auth_authen}), injected locally via non_smtpd_milters, matched by originating_daemons / originating_ports, or connecting from trusted_networks. |
originating_daemons |
list | ["ORIGINATING", "MSA"] |
{daemon_name} macro values (case-insensitive) treated as outbound/originating sessions in "auto" mode. |
originating_ports |
list | ["587", "465"] |
{daemon_port} macro values treated as outbound/originating sessions in "auto" mode. |
resolvers |
list | System DNS | Upstream DNS resolvers used by authentication and blocklist modules. |
timeout_ms |
int | 3000 |
Default timeout in milliseconds for DNS queries. |
trusted_networks |
list | [] |
Pre-compiled CIDR ranges for internal/trusted relays. Automatically inherited by iprev, spf, dkim, dmarc, arc, greylist, and dnsbl unless overridden locally. |
pre_flight_check |
bool | false |
Validates resolvers, key files, and sockets on startup/reload. |
pre_flight_verbose |
bool | false |
Enables verbose diagnostic logging during pre-flight checks. |
Module Reference
All modules share standard lifecycle controls:
enabled: Boolean (trueby default if the module block is present).resolvers&timeout_ms: Override the global DNS settings for that specific module.pre_flight_check&pre_flight_verbose: Override the global startup check behavior.actions: Used by authentication and ClamAV modules to map evaluation outcomes (such asfail,softfail,permerror, ortemperror) to a milter disposition ("none","reject","tempfail","quarantine", or"discard"). Any unspecified outcome defaults to"none". (By contrast, thednsblmodule uses separateresultandactionfields per rule.)
IPRev Module (iprev)
Performs an asynchronous Forward-Confirmed Reverse DNS (IP → PTR → A/AAAA)
lookup on connect for routable public IPs, automatically skipping non-public IP space (IANA
reserved, multicast, and US DoD blocks). Results are stamped into
Authentication-Results (iprev=<status> policy.iprev=<ip> (<ptr>))
and shared with the dnsbl module for smtp.rdns lookups. Any
rejection policies are skipped for trusted_networks.
If this module is disabled, GoMilterD will attempt to fall back to reverse DNS information
provided by the MTA via connect-phase milter macros ({client_name},
{client_ptr}, {client_resolve}, and
_) for downstream modules such as dnsbl, but it will not stamp
iprev= results or enforce actions (reject,
tempfail, quarantine).
iprev:
enabled: true
apply_results: "eom" # "immediate", "connect", "helo", "mail", "rcpt", "eoh", or "eom"
auth_results: true # Stamp iprev= in Authentication-Results
actions:
no_ptr: "none" # "none", "reject", "tempfail", or "quarantine"
fail: "none" # "none", "reject", "tempfail", or "quarantine"
temperror: "none" # "none", "tempfail", "reject", or "quarantine"
| Parameter | Type | Default | Description |
|---|---|---|---|
enabled | bool | true | Enables or disables the IPRev module. |
apply_results | string | "eom" | SMTP phase to enforce actions ("immediate", "connect", "helo", "mail", "rcpt", "eoh", or "eom"). |
auth_results | bool | true | Records iprev= in the Authentication-Results header. |
actions | map | {} | Maps IPRev results (no_ptr, fail, temperror) to milter actions (none, reject, tempfail, quarantine). Unspecified results default to none. |
SPF Module (spf)
Evaluates Sender Policy Framework (RFC 7208) records for both HELO/EHLO and
MAIL FROM identities. Lookups run asynchronously in the background unless
apply_results is set to an early SMTP phase.
spf:
enabled: true
apply_results: "eom" # "immediate", "helo", "mail", "rcpt", "eoh", or "eom"
check_helo: true
check_mail_from: true
ignore_authenticated: true # Skip SPF checks for SMTP-authenticated clients
# Header & Reporting
auth_results: true
received_spf: false # Stamp RFC 7208 Received-SPF header
trace: false # Injects detailed X-SPF-Trace debugging headers
trusted_networks: [] # Inherits global trusted_networks if omitted
ignore_domains: [] # Exempt sender domains
# Result-to-Action Mapping ("none", "reject", "tempfail", or "quarantine")
actions:
fail: "reject"
softfail: "none"
permerror: "reject"
temperror: "tempfail"
neutral: "none"
none: "none"
# RFC 7208 Resource Limits
max_lookups: 10 # Clamped between 1 and 20
max_void_lookups: 2
| Parameter | Type | Default | Description |
|---|---|---|---|
enabled | bool | true | Enables or disables the SPF module. |
apply_results | string | "eom" | SMTP phase to enforce actions ("immediate", "helo", "mail", "rcpt", "eoh", or "eom"). |
check_helo | bool | true | Evaluates SPF against the HELO/EHLO identity. |
check_mail_from | bool | true | Evaluates SPF against the MAIL FROM envelope sender. |
ignore_authenticated | bool | true | Skips SPF evaluation for SMTP-authenticated clients. |
auth_results | bool | true | Records the SPF outcome in the Authentication-Results header. |
received_spf | bool | false | Stamps an RFC 7208 Received-SPF header. |
trace | bool | false | Injects X-SPF-Trace headers with lookup diagnostics. |
trusted_networks | list | Global | CIDR ranges exempt from SPF enforcement. |
ignore_domains | list | [] | Sender domains exempt from SPF enforcement. |
actions | map | {} | Maps SPF results (fail, softfail, permerror, temperror, neutral, none) to milter actions (none, reject, tempfail, quarantine). Unspecified results default to none. |
max_lookups | int | 10 | Maximum DNS mechanism lookups per evaluation (RFC 7208; clamped between 1 and 20). |
max_void_lookups | int | 2 | Maximum void (NXDOMAIN/empty) lookups allowed before returning permerror. |
DKIM Module (dkim)
Validates incoming DKIM-Signature headers (RFC 6376 / RFC 8301) and signs
outbound mail using RSA private keys.
dkim:
enabled: true
verify: true # Verify incoming DKIM-Signature headers
auth_results: true # Stamp dkim= in Authentication-Results
trace: false
min_key_bits: 1024
max_signatures: 3
apply_results: "eom"
allow_sha1: false # RFC 8301 deprecates rsa-sha1
must_be_signed: [] # Sender From: domains that must pass DKIM
# Result-to-Action Mapping ("none", "reject", "tempfail", "quarantine", or "discard")
actions:
fail: "none"
policy: "none" # e.g., deprecated rsa-sha1
no_signature: "none"
permerror: "none"
temperror: "none"
signature_error: "reject" # Outbound signing failure
# Outbound Signing
sign: true
sign_authenticated: true
sign_trusted: true
canonicalization: "relaxed/relaxed" # "header/body": "simple" or "relaxed"
sign_headers:
- "From"
- "To"
- "Subject"
- "Date"
- "Message-ID"
- "MIME-Version"
- "Content-Type"
oversign_headers: # Prevents header injection
- "From"
trusted_networks: # Inherits global trusted_networks if omitted
- "127.0.0.0/8"
- "10.0.0.0/8"
keys:
- domain: "example.com"
selector: "mail"
file: "/etc/gomilterd/dkim/example.pem"
- domain: "customer.net"
selector: "x"
file: "/etc/gomilterd/dkim/customer.pem"
| Parameter | Type | Default | Description |
|---|---|---|---|
enabled | bool | true | Enables or disables the DKIM module. |
verify | bool | true | Validates incoming DKIM-Signature headers. |
auth_results | bool | true | Records DKIM verification outcomes in Authentication-Results. |
trace | bool | false | Injects X-DKIM-Trace headers with lookup diagnostics. |
min_key_bits | int | 1024 | Minimum RSA public key size accepted during verification. |
max_signatures | int | 3 | Maximum DKIM-Signature headers verified per message. |
apply_results | string | "eom" | SMTP phase to enforce verification actions. |
allow_sha1 | bool | false | Allows verification of deprecated rsa-sha1 signatures. When false (RFC 8301), rsa-sha1 signatures return dkim=policy (rsa-sha1 deprecated). |
must_be_signed | list | [] | Sender From: domains that must carry a passing DKIM signature; messages from listed domains without a valid signature are rejected. |
actions | map | {} | Maps DKIM outcomes (fail, policy, no_signature, permerror, temperror, signature_error) to milter actions (none, reject, tempfail, quarantine, discard). Unspecified results default to none. |
sign | bool | false | Enables outbound DKIM signing. |
sign_authenticated | bool | true | Signs mail submitted by SMTP-authenticated clients. |
sign_trusted | bool | true | Signs mail originating from trusted_networks. |
canonicalization | string | "simple/simple" | Header/body canonicalization mode ("simple" or "relaxed" for each, e.g., "relaxed/relaxed" or "relaxed/simple"). |
sign_headers | list | RFC 6376 set | List of header names included in outbound DKIM-Signature headers. |
oversign_headers | list | [] | Headers signed one additional time to prevent downstream header-injection attacks. |
trusted_networks | list | Global | CIDR ranges eligible for outbound signing when sign_trusted is enabled. |
keys | list | [] | Signing key definitions; each entry requires domain, selector, and file (PEM private key path). |
Generating & Deploying Signing Keys:
Both dkim and arc support PEM-encoded RSA (2048-bit recommended) and Ed25519 (RFC 8463) private keys.
RSA (2048-bit):
# 1. Generate a 2048-bit RSA private key
openssl genrsa -out /etc/gomilterd/dkim/example.pem 2048
chmod 600 /etc/gomilterd/dkim/example.pem
# 2. Extract the public key for DNS
openssl rsa -in /etc/gomilterd/dkim/example.pem -pubout -outform PEM
Publish the base64 public key (everything between BEGIN PUBLIC KEY and END PUBLIC KEY, stripped of newlines) as a DNS TXT record at <selector>._domainkey.<domain>:
mail._domainkey.example.com. IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A..."
Ed25519 (RFC 8463):
# 1. Generate an Ed25519 private key (PKCS#8 PEM)
openssl genpkey -algorithm ED25519 -out /etc/gomilterd/dkim/example-ed25519.pem
chmod 600 /etc/gomilterd/dkim/example-ed25519.pem
# 2. Extract the raw 32-byte base64 public key for DNS
openssl pkey -in /etc/gomilterd/dkim/example-ed25519.pem -pubout -outform DER | tail -c 32 | base64
Publish the resulting 44-character base64 string as a DNS TXT record at <selector>._domainkey.<domain>:
ed25519._domainkey.example.com. IN TXT "v=DKIM1; k=ed25519; p=<44-char-base64-key>"
DMARC Module (dmarc)
Evaluates DMARC alignment (RFC 7489) against the From header domain using
results collected from the spf and dkim modules, honoring the
sending domain's published adkim= and aspf= alignment tags.
dmarc:
enabled: true
auth_results: true
trace: false
ignore_authenticated: true
required_headers: false # Enforce RFC 5322 §3.6 header count requirements
reject_multi_value_from: false
reject_string: "rejected by DMARC policy for %s"
# Inherits global trusted_networks if omitted
trusted_networks:
- "127.0.0.0/8"
- "10.0.0.0/8"
ignore_domains: []
# Result-to-Action Mapping ("policy", "none", "reject", "tempfail", or "quarantine")
# "policy" honors the domain's p=/sp= directive
actions:
fail: "policy"
permerror: "none"
temperror: "none"
| Parameter | Type | Default | Description |
|---|---|---|---|
enabled | bool | true | Enables or disables the DMARC module. |
auth_results | bool | true | Records DMARC evaluation outcomes in Authentication-Results. |
trace | bool | false | Injects X-DMARC-Trace headers with lookup diagnostics. |
ignore_authenticated | bool | false | Skips DMARC evaluation for SMTP-authenticated clients. |
required_headers | bool | false | Rejects messages that violate RFC 5322 §3.6 header count requirements. |
reject_multi_value_from | bool | false | Rejects messages containing multiple From: addresses with differing domains. |
reject_string | string | "rejected by DMARC policy for %s" | Custom SMTP rejection message; %s is replaced with the From domain. |
trusted_networks | list | Global | CIDR ranges exempt from DMARC evaluation. |
ignore_domains | list | [] | Sender From: domains exempt from DMARC evaluation. |
actions | map | {} | Maps DMARC outcomes (fail, permerror, temperror) to milter actions (policy, none, reject, quarantine, tempfail). "policy" enforces the domain's published p=/sp= directive; unspecified results default to none (header-only by default). |
ARC Module (arc)
Validates incoming Authenticated Received Chain (RFC 8617) headers and seals
forwarded/mailing-list messages with new ARC-Seal,
ARC-Message-Signature, and ARC-Authentication-Results headers.
arc:
enabled: true
verify: true # Verify incoming ARC chains
auth_results: true # Stamp arc= in Authentication-Results
min_key_bits: 1024
# Outbound Sealing
seal: true
seal_authenticated: true
seal_trusted: true
canonicalization: "relaxed/relaxed" # "header/body": "simple" or "relaxed"
seal_headers:
- "From"
- "To"
- "Subject"
- "Date"
- "Message-ID"
- "MIME-Version"
- "Content-Type"
oversign_headers: []
trusted_networks: [] # Inherits global trusted_networks if omitted
keys:
- domain: "example.com"
selector: "arc2026"
file: "/etc/gomilterd/arc/example.pem"
| Parameter | Type | Default | Description |
|---|---|---|---|
enabled | bool | true | Enables or disables the ARC module. |
verify | bool | true | Validates incoming ARC-Seal, ARC-Message-Signature, and ARC-Authentication-Results chains. |
auth_results | bool | true | Records ARC chain verification outcomes (arc=) in Authentication-Results. |
min_key_bits | int | 1024 | Minimum RSA public key size accepted during ARC verification. |
seal | bool | false | Enables outbound ARC sealing for forwarded/mailing-list messages. |
seal_authenticated | bool | true | Seals mail submitted by SMTP-authenticated clients. |
seal_trusted | bool | true | Seals mail originating from trusted_networks. |
canonicalization | string | "simple/simple" | Header/body canonicalization mode ("simple" or "relaxed" for each). |
seal_headers | list | RFC 8617 set | List of header names covered by ARC-Message-Signature. |
oversign_headers | list | [] | Headers signed one additional time to prevent header injection. |
trusted_networks | list | Global | CIDR ranges eligible for outbound sealing when seal_trusted is enabled. |
keys | list | [] | Sealing key definitions; each entry requires domain, selector, and file (PEM private key path). |
BIMI Module (bimi)
Evaluates Brand Indicators for Message Identification at End-of-Message only after DMARC
passes with an enforcing policy (p=quarantine or p=reject). Strips
any spoofed inbound BIMI-Location and BIMI-Indicator headers before
stamping validated headers and recording bimi= in
Authentication-Results.
bimi:
enabled: true
auth_results: true # Stamp bimi= in Authentication-Results
require_vmc: true # Require a valid Verified Mark Certificate
default_selector: "default" # Selector used when BIMI-Selector header is absent
bimi_location: true # Injects BIMI-Location header when DMARC + BIMI pass
bimi_indicator: false # Injects base64 BIMI-Indicator SVG header
max_svg_size: 32768 # 32 KB limit per BIMI SVG Tiny P/S spec
| Parameter | Type | Default | Description |
|---|---|---|---|
enabled | bool | true | Enables or disables the BIMI module. |
auth_results | bool | true | Records BIMI evaluation outcomes (bimi=) in Authentication-Results. |
require_vmc | bool | true | Requires a valid Verified Mark Certificate (VMC) before passing BIMI. |
default_selector | string | "default" | DNS selector queried when no BIMI-Selector header is present. |
bimi_location | bool | true | Injects the BIMI-Location header when both DMARC and BIMI pass. |
bimi_indicator | bool | false | Injects the base64-encoded BIMI-Indicator SVG header when BIMI passes. |
max_svg_size | int | 32768 | Maximum allowed SVG indicator payload size in bytes (32 KB per BIMI SVG Tiny P/S specification). |
DNSBL Module (dnsbl)
Queries IPv4, IPv6, domain, and hash reputation zones asynchronously across SMTP
phases and message headers, caching lookups per session. Non-public IP space (IANA
reserved/RFC 1918, multicast, and US DoD blocks) is automatically skipped for both direct
IP queries and header IP extraction. Positive hits optionally trigger a
TXT query for diagnostic context, and outcomes are recorded in a standardized
DNSBL-Results header for
downstream scoring engines.
Module Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
enabled | bool | true | Enables or disables the DNSBL module. |
dnsbl_results | bool | true | Injects the DNSBL-Results header at End-of-Message. |
apply_results | string | "eom" | Synchronization boundary for async lookups and action enforcement ("immediate" or "eom"). |
resolvers | list | Global | Optional module-level DNS resolver overrides. |
timeout_ms | int | Global | Optional module-level DNS query timeout in milliseconds. |
trusted_networks | list | Global | CIDR ranges exempt from connecting-IP checks and skipped when extracting IPs from headers. |
zones | list | [] | List of reputation zones to query. |
keys | map | {} | Named customer/API keys for commercial DNSBLs. Supports env:VAR, ${VAR}, file:/path/to/key, or literal string. Referenced via {key_name} and automatically stripped from headers, logs, and reject messages. |
Zone Parameters (zones[])
| Parameter | Type | Default | Description |
|---|---|---|---|
name | string | (Required) | DNS zone suffix to query (e.g., ip.bl.example.net). Supports {key_name} placeholders defined under keys. |
enabled | bool | true | Enables or disables this zone. |
resolvers | list | Module | Optional per-zone DNS resolver overrides. |
dnsbl_results | bool | true | Records results from this zone in DNSBL-Results. |
timeout_ms | int | Module | Optional per-zone DNS query timeout in milliseconds (0 = inherit). |
type | string | (Required) | Query type: ip4, ip6, domain, or hash. |
sources | list | (Required) | Entities to evaluate, e.g., smtp.remote-ip or header.received:2 (see tables below). |
fetch_txt | bool | true | Performs a TXT lookup on positive A-record hits for dns.txt metadata. |
result | string | "pass" | Default DNSBL-Results status when unlisted (NXDOMAIN): pass, fail, neutral, policy, unknown, or ignore (omits entry from header). |
action | string | "none" | Default milter action when unlisted (NXDOMAIN): none, reject, tempfail, or quarantine. |
rules | list | [] | Ordered list of A-record match rules. |
Supported Sources (zones[].sources[])
| Source | Compatible type |
Extracted Value |
|---|---|---|
smtp.remote-ip | ip4, ip6 | Connecting SMTP client IP address. |
smtp.helo | domain, ip4, ip6 | Domain name or address literal from HELO/EHLO. |
smtp.rdns | domain | Reverse DNS (PTR) hostname from the iprev module (falls back to MTA connect-phase macros if iprev is disabled). |
smtp.mailfrom | domain, hash | Envelope sender domain (domain) or full address (hash) from MAIL FROM. |
smtp.rcptto | domain, hash | Envelope recipient domain (domain) or full address (hash) from RCPT TO. |
header.received[:<selector>] | ip4, ip6, domain | Relay IP address (ip4/ip6) or relay hostname/HELO domain (domain) from untrusted, publicly routable Received headers. |
header.<name>[:<selector>] | domain, hash, ip4, ip6 | Extracts IPs from IP headers (X-Originating-IP, X-Sender-IP, X-Real-IP, X-Forwarded-For, X-Client-IP), domains from Message-ID/In-Reply-To, and addresses/domains from other RFC 5322 headers (e.g., header.from, header.reply-to, header.return-path). |
Header Selectors (header.<name>[:<selector>])
Any header.* source accepts an optional :<selector> suffix
controlling which matching occurrences of that header are evaluated (defaulting to
:1 if omitted). Only headers yielding at least one valid, publicly routable,
non-trusted value increment the occurrence counter, so internal relays in
trusted_networks do not consume selector slots.
| Selector | Behavior |
|---|---|
(omitted) or :1 | Evaluates the first valid occurrence (top-most header). |
:N | Evaluates up to the first N valid occurrences (e.g., header.received:2). |
:all | Evaluates every valid occurrence in the message (e.g., header.reply-to:all). |
:last | Evaluates only the final valid occurrence, dispatched at End-of-Headers (e.g., header.received:last). |
Rule Parameters (zones[].rules[])
| Parameter | Type | Default | Description |
|---|---|---|---|
match | string | (Required) | Matcher for returned A records: single IP (127.0.0.2), hex (0x7F000010), IP range (127.0.0.4-127.0.0.9), shorthand last-octet range (127.0.0.4-9), or CIDR (127.255.255.0/24). |
bitmask | string | "" | Optional IPv4 (255.255.0.4) or hex (0xFFFF0004) bitmask applied to the A record before comparison: (A & bitmask) == match. Requires match to be a single IP or hex value. |
sources | list | [] | Optional list of canonical sources (e.g., smtp.remote-ip, header.received) restricting which sources this rule applies to. If omitted or empty, the rule applies to all sources configured on the zone. |
result | string | "fail" | DNSBL-Results status recorded on match (fail, pass, policy, neutral, unknown, or ignore). |
action | string | "none" | Milter disposition on match (none, reject, tempfail, or quarantine). |
comment | string | "" | Optional RFC 5322 comment emitted after the result in DNSBL-Results (e.g., phish, abuse; parentheses are stripped automatically). |
Evaluation Precedence:
- Matched
rules[]entry: Evaluates rules in order, skipping any rule whosesourcesfilter does not include the current source, and applies the first matching rule'sresult,action, andcomment. - Unmatched
Arecord: Recorded asresult: unknownwithaction: none. - Unlisted (
NXDOMAIN): Falls back to the zone'sresult(defaultpass) andaction(defaultnone). - DNS failure: Recorded as
temperror(timeout/SERVFAIL) orpermerrorwithaction: none.
dnsbl:
enabled: true
dnsbl_results: true
apply_results: "eom"
timeout_ms: 3000
trusted_networks:
- "127.0.0.0/8"
- "10.0.0.0/8"
keys:
provider_a: "env:DNSBL_KEY_A"
provider_b: "file:/etc/gomilterd/keys/provider_b.key"
zones:
# Keyed Commercial IPv4 Blocklist (key is stripped from headers/rejects)
- name: "ip.{provider_a}.bl.example.com"
enabled: true
dnsbl_results: true
type: "ip4"
sources:
- "smtp.remote-ip"
- "header.received:2" # First 2 untrusted, public Received hops
fetch_txt: true
result: "pass" # Unlisted (NXDOMAIN) -> pass
action: "none"
rules:
- match: "127.0.0.2"
result: "fail"
action: "reject"
- match: "127.0.0.4-127.0.0.9"
sources:
- "smtp.remote-ip"
result: "fail"
action: "quarantine"
- match: "127.0.0.4-127.0.0.9"
sources:
- "header.received"
result: "fail"
action: "none"
- match: "127.255.255.0/24"
result: "policy"
action: "none"
- match: "0x7F000010"
result: "ignore"
action: "none"
# Domain Blocklist (Bitmask)
- name: "dn.example.com"
type: "domain"
sources:
- "smtp.mailfrom"
- "header.from" # Defaults to :1
- "header.reply-to:all" # Check every Reply-To header
fetch_txt: true
result: "ignore" # Omit clean (NXDOMAIN) lookups from header
action: "none"
rules:
- match: "0x7F000002"
bitmask: "0xFF000002"
result: "fail"
action: "reject"
comment: "phish"
# IPv4 Allowlist (DNSWL)
- name: "list.dnswl.example.com"
type: "ip4"
sources:
- "smtp.remote-ip"
fetch_txt: true
result: "neutral" # Unlisted (NXDOMAIN) -> neutral
action: "none"
rules:
- match: "127.0.0.0/16"
result: "pass"
action: "none"
ClamAV Module (clamav)
Streams raw message headers and body chunks directly to clamd over Unix or
TCP sockets using zINSTREAM without buffering entire messages to disk,
letting libclamav handle format detection and MIME unpacking natively.
clamav:
enabled: true
socket: "unix:/var/run/clamav/clamd.ctl" # "unix:/path/to/sock" or "tcp:127.0.0.1:3310"
add_header: "none" # "none", "add", or "replace" (X-Virus-Status)
reject_string: "Virus found: %v" # %v = ClamAV signature name
ignore_authenticated: false
trusted_networks: [] # Explicit bypass list (does not auto-skip global trusted_networks)
# Result-to-Action Mapping ("none", "reject", "tempfail", or "quarantine")
actions:
virus: "reject"
fail: "tempfail"
max_file_size: 26214400 # 25 MB max streamed message size (0 = unlimited)
dial_timeout_ms: 2000
read_timeout_ms: 10000
| Parameter | Type | Default | Description |
|---|---|---|---|
enabled | bool | true | Enables or disables the ClamAV module. |
socket | string | (Required) | clamd endpoint (unix:/path/to/sock or tcp:host:port). |
add_header | string | "none" | Controls X-Virus-Status header injection: "none", "add", or "replace". |
reject_string | string | "Virus found: %v" | Custom SMTP rejection message; %v is replaced with the detected signature name. |
ignore_authenticated | bool | false | Skips virus scanning for SMTP-authenticated clients. |
trusted_networks | list | [] | Explicit CIDR ranges exempt from virus scanning (does not automatically inherit global trusted_networks). |
actions | map | {} | Maps scan outcomes (virus, fail) to milter actions (none, reject, tempfail, quarantine). Unspecified results default to none. |
max_file_size | int | 26214400 | Maximum total message size in bytes to stream to clamd (0 = unlimited). |
dial_timeout_ms | int | 2000 | Timeout in milliseconds when connecting to clamd. |
read_timeout_ms | int | 10000 | Timeout in milliseconds when waiting for a scan response from clamd. |
Greylist Module (greylist)
Maintains a 32-shard, FNV-1a hashed in-memory triplet store
(Client IP, MAIL FROM, RCPT TO) with randomized eviction sampling to defer
unknown senders with a 451 4.7.1 temporary failure. Connections matching
trusted_networks, ignore_domains, or authenticated sessions
(ignore_authenticated) bypass greylisting.
greylist:
enabled: true
delay_seconds: 300 # Minimum retry wait time (5 minutes)
expire_seconds: 2592000 # Triplet retention window (30 days)
max_records: 500000
ipv4_prefix: 24 # Subnet mask for IPv4 triplet hashing
ipv6_prefix: 64 # Subnet mask for IPv6 triplet hashing
ignore_authenticated: true # Bypass SMTP-authenticated clients
add_header: true # Stamp X-Greylist header
trusted_networks: [] # Inherits global trusted_networks if omitted
ignore_domains:
- "trusted-partner.com"
save_mode: "none" # "none", "snapshot", or "wal"
save_file: "/var/lib/gomilterd/greylist.db"
save_interval: 60 # Minutes between snapshots
| Parameter | Type | Default | Description |
|---|---|---|---|
enabled | bool | true | Enables or disables the Greylist module. |
delay_seconds | int | 300 | Minimum retry wait time in seconds before a triplet is accepted. |
expire_seconds | int | 2592000 | Triplet retention window in seconds (default 30 days). |
max_records | int | 500000 | Maximum in-memory triplets before randomized eviction sampling triggers. |
ipv4_prefix | int | 24 | CIDR prefix length applied to IPv4 client addresses before triplet hashing. |
ipv6_prefix | int | 64 | CIDR prefix length applied to IPv6 client addresses before triplet hashing. |
ignore_authenticated | bool | true | Bypasses greylisting for SMTP-authenticated clients. |
add_header | bool | true | Injects an X-Greylist header with delay/pass metadata. |
trusted_networks | list | Global | CIDR ranges exempt from greylisting. |
ignore_domains | list | [] | Sender domains exempt from greylisting. |
save_mode | string | "none" | Persistence strategy: "none", "snapshot", or "wal". |
save_file | string | "" | File path for persisting greylist state when save_mode is not "none". |
save_interval | int | 60 | Interval in minutes between periodic snapshots when save_mode: "snapshot". |
Authentication-Results Module (auth_results)
Aggregates results from all active authentication modules (iprev,
spf, dkim, dmarc, arc,
bimi) into a single RFC 8601 Authentication-Results header.
auth_results:
enabled: true
| Parameter | Type | Default | Description |
|---|---|---|---|
enabled | bool | true | Enables or disables stamping the aggregated RFC 8601 Authentication-Results header. |
Telemetry Module (telemetry)
Emits lightweight, zero-PII, fire-and-forget UDP datagrams at End-of-Message for external
metrics, logging, or threat-intelligence collectors. Sessions from
trusted_networks are skipped, and UDP write errors are ignored so telemetry
never affects mail delivery.
Each datagram consists of a 24-byte header (GM magic bytes, version
0x01, reserved byte, big-endian key_id, and a 16-byte truncated
HMAC-SHA256 tag computed over header[0:8] + payload) followed by a compact
Protobuf payload (sized to fit within an IPv6-safe 1280-byte UDP MTU).
telemetry:
enabled: true
targets:
- name: "collector-primary"
enabled: true
dest: "192.0.2.10:9100, 192.0.2.11:9100" # Comma, space, or tab-separated host:port list
key_id: 1001
key: "file:/etc/gomilterd/keys/telemetry.key"
fields:
smtp.remote-ip: true
conn.flags: true
smtp.helo: true
smtp.rdns: true
smtp.mailfrom: true # Domain only (no local-part)
header.from: true # Domain only; omitted if identical to smtp.mailfrom
Target Parameters (targets[])
| Parameter | Type | Default | Description |
|---|---|---|---|
name | string | target[i] | Optional label used in configuration error messages. |
enabled | bool | true | Enables or disables this target. |
dest | string | (Required) | One or more host:port UDP endpoints separated by commas, spaces, or tabs. |
key_id | uint32 | 0 | Unsigned 32-bit key identifier stamped into the packet header for receiver-side key lookup. |
key | string | (Required) | Shared HMAC-SHA256 secret (minimum 16 bytes). Supports file:/path/to/key, env:VAR, or a literal string; even-length hex strings of 32+ characters are automatically hex-decoded. |
fields | map | (All true) | Per-target boolean toggles for smtp.remote-ip, conn.flags, smtp.helo, smtp.rdns, smtp.mailfrom, and header.from. Only domains (never local-parts or message content) are transmitted. |
Custom Modules
Integrating custom modules is straightforward. GoMilterD handles the milter protocol and
session lifecycle so each module can focus strictly on its own logic. A
skeleton.go file is included in the main package demonstrating the
interface functions required for any custom module.
MTA Integration
Postfix
Add the following to /etc/postfix/main.cf:
# Milter Socket Connection
smtpd_milters = unix:/var/run/gomilterd/gomilterd.sock
non_smtpd_milters = $smtpd_milters
# Failure Handling ('tempfail' queues mail on milter outage; 'accept' bypasses)
milter_default_action = tempfail
# Milter Protocol Version 6
milter_protocol = 6
# Required Macros
milter_connect_macros = j i _ {daemon_name} {daemon_port} {client_name} {client_ptr} {client_resolve}
milter_helo_macros = s {tls_version} {cipher} {cipher_bits} {cert_authority} {cert_subject} {cert_issuer}
milter_mail_macros = i f {auth_type} {auth_authen} {auth_author} {auth_method}
milter_rcpt_macros = i {rcpt_addr} {rcpt_domain}
For explicit submission tagging in /etc/postfix/master.cf, override
milter_macro_daemon_name on your submission services so GoMilterD
deterministically identifies them as outbound via originating_daemons:
submission inet n - y - - smtpd
-o milter_macro_daemon_name=ORIGINATING
submissions inet n - y - - smtpd
-o smtpd_tls_wrappermode=yes
-o milter_macro_daemon_name=ORIGINATING
smtpd runs chrooted inside
/var/spool/postfix, set address: "/var/spool/postfix/gomilterd/gomilterd.sock"
in gomilterd.yaml and smtpd_milters = unix:gomilterd/gomilterd.sock
in /etc/postfix/main.cf.
Sendmail
Add the following to /etc/mail/sendmail.mc, rebuild sendmail.cf, and restart Sendmail:
dnl Expose required macros across SMTP phases
define(`confMILTER_MACROS', `i, s, f, {daemon_name}, {daemon_port}, {client_addr}, {client_name}, {client_resolve}, {mail_addr}, {auth_type}, {auth_authen}')
INPUT_MAIL_FILTER(`gomilterd', `S=local:/var/run/gomilterd/gomilterd.sock, T=R:4s')
make -C /etc/mail
sudo systemctl restart sendmail
Migrating Existing Milters (convert.py)
GoMilterD includes a zero-dependency Python 3 migration script (convert.py)
that inspects your existing Postfix or Sendmail configuration and companion milter files
to generate a starter gomilterd.yaml.
# Auto-detect Postfix or Sendmail and print starter YAML to stdout
python3 convert.py
# Write directly to /etc/gomilterd/gomilterd.yaml
sudo python3 convert.py -o /etc/gomilterd/gomilterd.yaml
# Explicitly target Sendmail or custom config paths
python3 convert.py --mta sendmail --sendmail-mc /etc/mail/sendmail.mc -o gomilterd.yaml
CLI Options
| Flag | Default | Description |
|---|---|---|
--mta | auto | Target MTA to inspect: auto, postfix, or sendmail. |
--main-cf | /etc/postfix/main.cf | Path to Postfix main.cf. |
--master-cf | /etc/postfix/master.cf | Path to Postfix master.cf. |
--sendmail-mc | /etc/mail/sendmail.mc | Path to Sendmail sendmail.mc. |
--sendmail-cf | /etc/mail/sendmail.cf | Path to Sendmail sendmail.cf (fallback if sendmail.mc is absent). |
-o, --output | (stdout) | Output path for the generated gomilterd.yaml. |
What It Imports
-
MTA Settings & RBLs: Reads
myhostname,mynetworks,smtpd_milters,master.cfmilter_macro_daemon_nameoverrides, andsmtpd/cleanupchroot status (automatically placing the Unix socket inside/var/spool/postfix/gomilterd/gomilterd.sockwhen chrooted). Native Postfix RBLs (reject_rbl_client,reject_rhsbl_*,postscreen_dnsbl_sites) and SendmailFEATURE(dnsbl)/FEATURE(enhdnsbl)zones are converted intodnsbl.zones. -
Companion Milters: Automatically parses OpenDKIM,
dkimpy-milter, OpenDMARC, OpenARC,smf-spf,spf-milter(Rust),pyspf-milter(Python),clamav-milter,milter-greylist, and Fastmailauthentication_milter(authentication_milter.json) for keys, trusted networks, actions, and sockets. -
Manual Review Flags: Emits
# TODOcomments in the generated YAML for any detectedrspamd,amavisd-milter,rbl-milter,milter-manager, or unrecognized milter sockets, as well as mismatched Postfixsmtpd/cleanupchroot settings.
# TODO comments in the
generated file and run gomilterd with pre_flight_check: true
before routing live MTA traffic to it.
Signals & Lifecycle Management
-
SIGHUP: Reloadsgomilterd.yamlatomically without dropping active connections. New connections immediately receive the updated configuration snapshot; ifnetworkoraddresschanged, the listener rebinds seamlessly. -
SIGINT/SIGTERM: Initiates a graceful shutdown with a 15-second drain timeout for in-flight SMTP sessions.
Standards & References
- Authentication-Results & IPRev: RFC 8601
- SPF (Sender Policy Framework): RFC 7208
- DKIM (DomainKeys Identified Mail): RFC 6376, RFC 8301, RFC 8463
- DMARC: RFC 7489
- ARC (Authenticated Received Chain): RFC 8617
- BIMI: BIMI Group Specifications
- DNSBL-Results Header:
draft-schneider-dnsbl-results-00.txt
Artwork & Trademark Notice
The GoMilterD logo is derived from the Go gopher, originally designed by Renée French and licensed under Creative Commons 4.0 Attribution (CC BY 4.0).
GoMilterD is an independent project and is not affiliated with, endorsed by, or an official release of Google or the Go project.