How to Configure Dkim Policy
A dkim policy uses public keys in DNS to prove that outgoing emails came from your domain. You set it up by creating a key pair, adding the public key to DNS, and turning on signing. Email servers need a clear way to trust the messages they get every day. Without cryptographic signing, bad actors can fake your domain name in the sender field. DomainKeys Identified Mail fixes this gap by attaching a digital signature to each message header. Receiving servers check this signature against your pub
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
A dkim policy uses public keys in DNS to prove that outgoing emails came from your domain. You set it up by creating a key pair, adding the public key to DNS, and turning on signing.
Email servers need a clear way to trust the messages they get every day. Without cryptographic signing, bad actors can fake your domain name in the sender field. DomainKeys Identified Mail fixes this gap by attaching a digital signature to each message header. Receiving servers check this signature against your public DNS record before they deliver the mail.
How a dkim policy works in practice
Your mail server holds a private key that no outside system can read. When an app or user sends an email, the server hashes the message body and headers. It then encrypts that hash with the private key to create the signature header. The receiving mail server reads the domain and selector name from that header. Next, the receiver runs a DNS query to fetch the matching public key record.
This setup affects every person, marketing tool, and background job that sends mail from your domain. If a third-party billing app sends receipts for you, it needs its own key pair. Each sending service should use a unique selector name so keys never overlap. Safe defaults start with strong key lengths and strict header selection rules. You should always sign the sender, subject, date, and message ID fields at a minimum. Signing these fields stops attackers from changing the core parts of an email in transit.
Key rotation and DNS setup steps
Managing keys takes steady care because static keys become risky over time. Teams should rotate their signing keys every few months to limit exposure from old credentials. Key rotation works best when you publish a new selector record in DNS first. Wait for the DNS record to spread across the internet before you switch active keys. Once the mail server signs with the new key, you can delete the old DNS record.
You also need to control who can edit DNS records and mail server settings. Often, an engineer logs in to a cloud console or mail host with broad admin rights. Static role permissions give that person full control over every domain zone and signing key. If an attacker steals an admin session, they can publish rogue keys in your DNS zone. They can also read raw database tables that hold customer emails, phone numbers, and card numbers.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Checking signatures and closing audit gaps
After you publish your public key, you must test how receiving servers handle your mail. Send a test message to an outside mailbox and read the raw message headers. Look for the results header that shows whether the signature check passed or failed. You should also pair your signing setup with a clear DMARC rule in DNS. DMARC tells receivers to reject or quarantine messages when the signature check fails.
DNS checks verify mail in transit, but they do not track internal admin actions. Once an engineer logs in to a mail server or database, static configs cannot see their queries. You have no clean audit log of who read private keys or exported user lists. Strong security requires tight controls on the actual sessions that manage your mail systems. Adding data masking also helps by rewriting emails or phone numbers in query results.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.
First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
What happens if a DKIM signature check fails?
The receiving server marks the check as failed in the message headers. It then checks your DMARC rule to decide whether to deliver, quarantine, or drop the email.
How many selectors can one domain have?
A domain can have as many selectors as you need in DNS. Giving each mail tool its own selector makes key rotation and debugging much easier.
Does DKIM encrypt the body of an email?
No, it only signs the message to prove the sender identity and check for tampering. The email text stays readable in plain form unless you use separate transport encryption.
Related guides
In this post