DOCUMENTATION · AGPLv3

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:

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
enabledbooltrueEnables or disables the IPRev module.
apply_resultsstring"eom"SMTP phase to enforce actions ("immediate", "connect", "helo", "mail", "rcpt", "eoh", or "eom").
auth_resultsbooltrueRecords iprev= in the Authentication-Results header.
actionsmap{}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
enabledbooltrueEnables or disables the SPF module.
apply_resultsstring"eom"SMTP phase to enforce actions ("immediate", "helo", "mail", "rcpt", "eoh", or "eom").
check_helobooltrueEvaluates SPF against the HELO/EHLO identity.
check_mail_frombooltrueEvaluates SPF against the MAIL FROM envelope sender.
ignore_authenticatedbooltrueSkips SPF evaluation for SMTP-authenticated clients.
auth_resultsbooltrueRecords the SPF outcome in the Authentication-Results header.
received_spfboolfalseStamps an RFC 7208 Received-SPF header.
traceboolfalseInjects X-SPF-Trace headers with lookup diagnostics.
trusted_networkslistGlobalCIDR ranges exempt from SPF enforcement.
ignore_domainslist[]Sender domains exempt from SPF enforcement.
actionsmap{}Maps SPF results (fail, softfail, permerror, temperror, neutral, none) to milter actions (none, reject, tempfail, quarantine). Unspecified results default to none.
max_lookupsint10Maximum DNS mechanism lookups per evaluation (RFC 7208; clamped between 1 and 20).
max_void_lookupsint2Maximum 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
enabledbooltrueEnables or disables the DKIM module.
verifybooltrueValidates incoming DKIM-Signature headers.
auth_resultsbooltrueRecords DKIM verification outcomes in Authentication-Results.
traceboolfalseInjects X-DKIM-Trace headers with lookup diagnostics.
min_key_bitsint1024Minimum RSA public key size accepted during verification.
max_signaturesint3Maximum DKIM-Signature headers verified per message.
apply_resultsstring"eom"SMTP phase to enforce verification actions.
allow_sha1boolfalseAllows verification of deprecated rsa-sha1 signatures. When false (RFC 8301), rsa-sha1 signatures return dkim=policy (rsa-sha1 deprecated).
must_be_signedlist[]Sender From: domains that must carry a passing DKIM signature; messages from listed domains without a valid signature are rejected.
actionsmap{}Maps DKIM outcomes (fail, policy, no_signature, permerror, temperror, signature_error) to milter actions (none, reject, tempfail, quarantine, discard). Unspecified results default to none.
signboolfalseEnables outbound DKIM signing.
sign_authenticatedbooltrueSigns mail submitted by SMTP-authenticated clients.
sign_trustedbooltrueSigns mail originating from trusted_networks.
canonicalizationstring"simple/simple"Header/body canonicalization mode ("simple" or "relaxed" for each, e.g., "relaxed/relaxed" or "relaxed/simple").
sign_headerslistRFC 6376 setList of header names included in outbound DKIM-Signature headers.
oversign_headerslist[]Headers signed one additional time to prevent downstream header-injection attacks.
trusted_networkslistGlobalCIDR ranges eligible for outbound signing when sign_trusted is enabled.
keyslist[]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
enabledbooltrueEnables or disables the DMARC module.
auth_resultsbooltrueRecords DMARC evaluation outcomes in Authentication-Results.
traceboolfalseInjects X-DMARC-Trace headers with lookup diagnostics.
ignore_authenticatedboolfalseSkips DMARC evaluation for SMTP-authenticated clients.
required_headersboolfalseRejects messages that violate RFC 5322 §3.6 header count requirements.
reject_multi_value_fromboolfalseRejects messages containing multiple From: addresses with differing domains.
reject_stringstring"rejected by DMARC policy for %s"Custom SMTP rejection message; %s is replaced with the From domain.
trusted_networkslistGlobalCIDR ranges exempt from DMARC evaluation.
ignore_domainslist[]Sender From: domains exempt from DMARC evaluation.
actionsmap{}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
enabledbooltrueEnables or disables the ARC module.
verifybooltrueValidates incoming ARC-Seal, ARC-Message-Signature, and ARC-Authentication-Results chains.
auth_resultsbooltrueRecords ARC chain verification outcomes (arc=) in Authentication-Results.
min_key_bitsint1024Minimum RSA public key size accepted during ARC verification.
sealboolfalseEnables outbound ARC sealing for forwarded/mailing-list messages.
seal_authenticatedbooltrueSeals mail submitted by SMTP-authenticated clients.
seal_trustedbooltrueSeals mail originating from trusted_networks.
canonicalizationstring"simple/simple"Header/body canonicalization mode ("simple" or "relaxed" for each).
seal_headerslistRFC 8617 setList of header names covered by ARC-Message-Signature.
oversign_headerslist[]Headers signed one additional time to prevent header injection.
trusted_networkslistGlobalCIDR ranges eligible for outbound sealing when seal_trusted is enabled.
keyslist[]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
enabledbooltrueEnables or disables the BIMI module.
auth_resultsbooltrueRecords BIMI evaluation outcomes (bimi=) in Authentication-Results.
require_vmcbooltrueRequires a valid Verified Mark Certificate (VMC) before passing BIMI.
default_selectorstring"default"DNS selector queried when no BIMI-Selector header is present.
bimi_locationbooltrueInjects the BIMI-Location header when both DMARC and BIMI pass.
bimi_indicatorboolfalseInjects the base64-encoded BIMI-Indicator SVG header when BIMI passes.
max_svg_sizeint32768Maximum 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
enabledbooltrueEnables or disables the DNSBL module.
dnsbl_resultsbooltrueInjects the DNSBL-Results header at End-of-Message.
apply_resultsstring"eom"Synchronization boundary for async lookups and action enforcement ("immediate" or "eom").
resolverslistGlobalOptional module-level DNS resolver overrides.
timeout_msintGlobalOptional module-level DNS query timeout in milliseconds.
trusted_networkslistGlobalCIDR ranges exempt from connecting-IP checks and skipped when extracting IPs from headers.
zoneslist[]List of reputation zones to query.
keysmap{}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
namestring(Required)DNS zone suffix to query (e.g., ip.bl.example.net). Supports {key_name} placeholders defined under keys.
enabledbooltrueEnables or disables this zone.
resolverslistModuleOptional per-zone DNS resolver overrides.
dnsbl_resultsbooltrueRecords results from this zone in DNSBL-Results.
timeout_msintModuleOptional per-zone DNS query timeout in milliseconds (0 = inherit).
typestring(Required)Query type: ip4, ip6, domain, or hash.
sourceslist(Required)Entities to evaluate, e.g., smtp.remote-ip or header.received:2 (see tables below).
fetch_txtbooltruePerforms a TXT lookup on positive A-record hits for dns.txt metadata.
resultstring"pass"Default DNSBL-Results status when unlisted (NXDOMAIN): pass, fail, neutral, policy, unknown, or ignore (omits entry from header).
actionstring"none"Default milter action when unlisted (NXDOMAIN): none, reject, tempfail, or quarantine.
ruleslist[]Ordered list of A-record match rules.

Supported Sources (zones[].sources[])

Source Compatible type Extracted Value
smtp.remote-ipip4, ip6Connecting SMTP client IP address.
smtp.helodomain, ip4, ip6Domain name or address literal from HELO/EHLO.
smtp.rdnsdomainReverse DNS (PTR) hostname from the iprev module (falls back to MTA connect-phase macros if iprev is disabled).
smtp.mailfromdomain, hashEnvelope sender domain (domain) or full address (hash) from MAIL FROM.
smtp.rcpttodomain, hashEnvelope recipient domain (domain) or full address (hash) from RCPT TO.
header.received[:<selector>]ip4, ip6, domainRelay IP address (ip4/ip6) or relay hostname/HELO domain (domain) from untrusted, publicly routable Received headers.
header.<name>[:<selector>]domain, hash, ip4, ip6Extracts 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 :1Evaluates the first valid occurrence (top-most header).
:NEvaluates up to the first N valid occurrences (e.g., header.received:2).
:allEvaluates every valid occurrence in the message (e.g., header.reply-to:all).
:lastEvaluates only the final valid occurrence, dispatched at End-of-Headers (e.g., header.received:last).

Rule Parameters (zones[].rules[])

Parameter Type Default Description
matchstring(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).
bitmaskstring""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.
sourceslist[]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.
resultstring"fail"DNSBL-Results status recorded on match (fail, pass, policy, neutral, unknown, or ignore).
actionstring"none"Milter disposition on match (none, reject, tempfail, or quarantine).
commentstring""Optional RFC 5322 comment emitted after the result in DNSBL-Results (e.g., phish, abuse; parentheses are stripped automatically).

Evaluation Precedence:

  1. Matched rules[] entry: Evaluates rules in order, skipping any rule whose sources filter does not include the current source, and applies the first matching rule's result, action, and comment.
  2. Unmatched A record: Recorded as result: unknown with action: none.
  3. Unlisted (NXDOMAIN): Falls back to the zone's result (default pass) and action (default none).
  4. DNS failure: Recorded as temperror (timeout/SERVFAIL) or permerror with action: 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
enabledbooltrueEnables or disables the ClamAV module.
socketstring(Required)clamd endpoint (unix:/path/to/sock or tcp:host:port).
add_headerstring"none"Controls X-Virus-Status header injection: "none", "add", or "replace".
reject_stringstring"Virus found: %v"Custom SMTP rejection message; %v is replaced with the detected signature name.
ignore_authenticatedboolfalseSkips virus scanning for SMTP-authenticated clients.
trusted_networkslist[]Explicit CIDR ranges exempt from virus scanning (does not automatically inherit global trusted_networks).
actionsmap{}Maps scan outcomes (virus, fail) to milter actions (none, reject, tempfail, quarantine). Unspecified results default to none.
max_file_sizeint26214400Maximum total message size in bytes to stream to clamd (0 = unlimited).
dial_timeout_msint2000Timeout in milliseconds when connecting to clamd.
read_timeout_msint10000Timeout 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
enabledbooltrueEnables or disables the Greylist module.
delay_secondsint300Minimum retry wait time in seconds before a triplet is accepted.
expire_secondsint2592000Triplet retention window in seconds (default 30 days).
max_recordsint500000Maximum in-memory triplets before randomized eviction sampling triggers.
ipv4_prefixint24CIDR prefix length applied to IPv4 client addresses before triplet hashing.
ipv6_prefixint64CIDR prefix length applied to IPv6 client addresses before triplet hashing.
ignore_authenticatedbooltrueBypasses greylisting for SMTP-authenticated clients.
add_headerbooltrueInjects an X-Greylist header with delay/pass metadata.
trusted_networkslistGlobalCIDR ranges exempt from greylisting.
ignore_domainslist[]Sender domains exempt from greylisting.
save_modestring"none"Persistence strategy: "none", "snapshot", or "wal".
save_filestring""File path for persisting greylist state when save_mode is not "none".
save_intervalint60Interval 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
enabledbooltrueEnables 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
namestringtarget[i]Optional label used in configuration error messages.
enabledbooltrueEnables or disables this target.
deststring(Required)One or more host:port UDP endpoints separated by commas, spaces, or tabs.
key_iduint320Unsigned 32-bit key identifier stamped into the packet header for receiver-side key lookup.
keystring(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.
fieldsmap(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
Postfix Chroot Note: If Postfix 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
--mtaautoTarget MTA to inspect: auto, postfix, or sendmail.
--main-cf/etc/postfix/main.cfPath to Postfix main.cf.
--master-cf/etc/postfix/master.cfPath to Postfix master.cf.
--sendmail-mc/etc/mail/sendmail.mcPath to Sendmail sendmail.mc.
--sendmail-cf/etc/mail/sendmail.cfPath to Sendmail sendmail.cf (fallback if sendmail.mc is absent).
-o, --output(stdout)Output path for the generated gomilterd.yaml.

What It Imports

Before cutting over: Review all # TODO comments in the generated file and run gomilterd with pre_flight_check: true before routing live MTA traffic to it.

Signals & Lifecycle Management

Standards & References

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.