Set Up Zimbra DKIM, SPF, and DMARC Without Breaking Mail

To authenticate outbound mail from Zimbra, generate the domain’s DKIM key with zmdkimkeyutil, publish its public-key TXT record, add an SPF TXT record for every authorized sending service, and start DMARC with a monitoring policy. Finally, send a message to an external mailbox and confirm that a passing SPF or DKIM result aligns with the visible From domain.

Illustrative scenario, not a tested deployment: ExampleCorp uses example.com for employee email and operates Zimbra at mail.example.com. Its only direct outbound mail server is assigned the documentation-only public IP 192.0.2.25. The organization also controls DNS for example.com and has a working mailbox at dmarc-reports@example.com. Replace these sample values with verified details from your environment.

1. Confirm where outbound mail actually leaves your network

Before editing DNS, identify the public IP address that recipient servers see. On the Zimbra host, hostname -f and hostname -I help identify the machine, but a private interface address or NAT address is not necessarily the outbound source IP. Check your firewall, outbound gateway, or SMTP relay configuration instead of assuming the host’s interface address will appear to recipients.

Terminal showing mail.example.com and example IPv4 addresses during the outbound-mail inventory
The terminal displays the hostname and interface addresses used to begin the sender inventory; the public sending IP must be checked separately.

For ExampleCorp, the sending path is Zimbra directly to the internet from 192.0.2.25. If an outbound security gateway or cloud relay sends the final SMTP connection, use that service’s approved SPF mechanism or public IP instead. List website notification services, CRM tools, newsletters, and any other systems that send using the same domain.

  • Have administrative SSH access to the Zimbra mail transfer agent (MTA) and permission to use the zimbra account.
  • Have access to the authoritative public DNS zone, not only the Zimbra admin console.
  • Confirm the domain already exists in Zimbra and determine whether DKIM is configured before adding or rotating keys.
  • Plan a mailbox or reporting service that can receive aggregate DMARC reports.

2. Generate a DKIM key in Zimbra and publish the public half

DKIM signs outgoing messages with a private key and lets recipients retrieve the matching public key from DNS. Zimbra documents DKIM signing using zmdkimkeyutil on an MTA server. Run the following as the zimbra operating-system user for a domain that does not already have a DKIM configuration:

su - zimbra
/opt/zimbra/libexec/zmdkimkeyutil -a -d example.com
Terminal command invoking Zimbra zmdkimkeyutil to add a DKIM key for example.com
A Zimbra terminal command creates domain DKIM signing data; use the selector actually returned by your server.

The command writes the signing data to Zimbra’s LDAP configuration and prints the DNS selector and public TXT record. The exact selector is generated by your installation; it is not a fixed string such as zimbra2026 shown in a sample screen. Copy the actual selector and complete public key from the command output. Never publish or share the private key.

Create one DNS TXT record at SELECTOR._domainkey.example.com, replacing SELECTOR with the returned value. Its content begins with v=DKIM1; k=rsa; p= and continues with the complete public-key material. DNS control panels usually ask for a relative host such as SELECTOR._domainkey; some ask for the full name. Avoid entering the domain twice.

DNS TXT editor showing a DKIM selector name under _domainkey and a public key value
A TXT record for the selector under _domainkey; the shortened key shown on screen must be replaced with the entire public key.

For long 2048-bit public keys, a DNS provider may split one TXT record into multiple quoted strings. That is acceptable when the strings belong to one TXT resource record and concatenate into the original value. Do not publish separate competing DKIM TXT records at the same selector. Zimbra’s official DKIM signing instructions document the add, query, update, and DNS verification commands. Use the documented -u operation only when intentionally rotating an existing key; leave the old selector record available long enough for already-sent mail to verify.

3. Publish one SPF record for the authorized sending IPs

SPF identifies which servers can send mail using the SMTP envelope domain. ExampleCorp sends directly from the one documentation IP, so it can publish this TXT value at example.com (often represented by @ in a DNS editor):

v=spf1 ip4:192.0.2.25 ~all
DNS TXT editor with the example.com root host and an SPF value authorizing 192.0.2.25
An SPF TXT record authorizes the example public sending IP address at the domain root.

ip4: authorizes that address, while ~all gives a soft-fail result for other senders. It is a reasonable initial choice while inventorying senders; -all asserts a harder failure for unmatched sources and should follow a complete audit. If a legitimate provider also sends for ExampleCorp, merge its officially documented include: mechanism or other supported authorization into the same SPF record. Never create multiple independent v=spf1 TXT records for one hostname.

SPF has a limit of ten DNS-lookup-causing mechanisms and modifiers during evaluation, not simply ten include: entries. Exceeding it produces a permanent error. IP literals do not consume that lookup budget. See RFC 7208, Sender Policy Framework, and Google’s SPF setup guidance for sender inventory and DNS publication details.

4. Publish DMARC at a monitoring policy before enforcing it

DMARC checks whether a passing DKIM signature domain or SPF-authenticated envelope domain aligns with the address people see in the message’s From: header. One aligned passing mechanism is enough for DMARC to pass; SPF and DKIM do not both have to pass every message. ExampleCorp starts with this TXT record:

DNS fieldExample value
TypeTXT
Host_dmarc
Valuev=DMARC1; p=none; rua=mailto:dmarc-reports@example.com

The p=none policy requests monitoring without asking receivers to quarantine or reject failed messages. The rua mailbox must exist and be able to accept aggregate reports; reports may arrive with a delay and are not guaranteed from every receiver. If reports go to a different organizational domain, extra destination authorization may be required. After you identify and fix legitimate senders that fail alignment, gradually consider p=quarantine and then p=reject, based on real results rather than a fixed waiting period.

Do not confuse SPF authorization with DMARC alignment. A bulk-mail service can pass SPF using its own envelope domain but still fail DMARC for From: employee@example.com unless it offers aligned DKIM signing or a custom aligned return-path domain. The rules and policy tags are defined in RFC 7489, DMARC.

5. Verify the DNS records and a real delivered message

Wait until the authoritative DNS service has accepted the records. From a machine with dig, query the public TXT answers. Replace SELECTOR with the actual DKIM selector reported by Zimbra:

dig +short TXT example.com
dig +short TXT SELECTOR._domainkey.example.com
dig +short TXT _dmarc.example.com

Check that you receive exactly one SPF policy at the sending domain, a complete DKIM public key at the intended selector, and the expected DMARC policy. If the new TXT record does not appear, inspect the authoritative nameservers and DNS panel’s handling of relative names; recursive resolver caches may take time to refresh. If your installation includes OpenDKIM’s test utility, Zimbra documents a further check using /opt/zimbra/common/sbin/opendkim-testkey with your domain, selector, and /opt/zimbra/conf/opendkim.conf.

Then send a normal message directly from user@example.com to an external account such as Gmail. Inspect the message’s original headers or authentication details and look for results such as dkim=pass, spf=pass, and dmarc=pass. Verify that the DKIM d= domain or SPF-authenticated domain aligns with example.com; a result shown as pass for an unrelated domain may not satisfy DMARC. Google documents these requirements in its Gmail sender guidelines.

If DKIM fails, compare the DNS selector against the message’s DKIM-Signature header and make sure a relay is not modifying signed content. If SPF fails, confirm the observed outbound IP, the envelope sender domain, and the complete sender inventory. If both pass but DMARC fails, investigate domain alignment rather than publishing a second SPF record. Passing these checks confirms authentication for that sample message; it does not guarantee inbox placement, which also depends on reputation and other sender requirements.

Leave a Comment

How to