Business email: how to configure SPF, DKIM and DMARC to protect your domain

Business email: how to configure SPF, DKIM and DMARC to protect your domain

Business email is an everyday tool for quotes, invoices, support and communication with customers. Precisely because a company's domain is recognizable, someone may try to use its name to send fraudulent messages. SPF, DKIM and DMARC help receiving servers distinguish authorized mail from messages that impersonate the sender. They are not switches to turn on blindly: they work well when they accurately describe every system that sends email for the company.

This guide explains how to inventory sending sources, publish DNS records, check the results and gradually introduce a stricter policy. The examples use demonstration domains and addresses: actual values must come from your email provider and the company's own inventory. The reference specifications are SPF, DKIM and DMARC.

Why an email domain deserves dedicated protection

A recipient may see an address in the From field that appears to belong to the company, but that visible text alone does not prove which system sent the message. An impersonation attempt could involve a payment request, a change of bank details or a communication apparently sent by a colleague. The resulting loss of trust may begin before anyone opens an attachment.

Authentication protocols do not read the writer's intentions. Instead, they check technical elements of the route and the domain. Their practical value is to reduce opportunities to use the business domain without authorization and to make visible sending activity that the company itself has forgotten to inventory. That is why configuration starts by organizing mail flows, not by copying a record from a generic guide.

What SPF, DKIM and DMARC do

SPF identifies which servers are authorized to send for a particular domain used in the SMTP transaction. DKIM adds a cryptographic signature to the message: the receiving server can verify it with a public key in DNS. DMARC relates those results to the domain shown in the From field and communicates a policy for messages that fail the check.

The three tools complement one another. A valid SPF result by itself may concern a domain other than the one the reader sees. A valid DKIM signature by itself may belong to an external provider. DMARC requires at least one of the two mechanisms to pass and to be aligned with the visible domain. Even when all three are active, controls against compromised accounts, deceptive content and dangerous attachments remain necessary.

Inventory every sender before touching DNS

The most common difficulty is not writing a record but remembering all the services that send email. Besides employees' mailboxes, the website, contact form, business software, newsletter platform, CRM, ticket system, automated invoices and devices that generate alerts may all send mail. Some send directly; others hand messages to the main mail provider.

For each source, record who manages it, which domain appears in From, which domain it uses as Return-Path, which servers or IP addresses deliver it and whether it applies a DKIM signature. A test sent to an external mailbox helps confirm the actual details. Before removing a service from the list, establish that it is no longer used: an old application may send only on rare occasions.

Distinguish the domain, mailboxes and DNS control panel

A domain may be registered with one company, have DNS managed by another and host email with a third provider. Publishing a record in the wrong control panel does not change the DNS zone read by recipients. Identify the authoritative nameservers and use the panel that actually governs the domain.

SPF, DKIM and DMARC changes usually involve TXT records. Do not replace MX records in the belief that they serve the same purpose: MX records indicate where incoming mail is received, whereas the three mechanisms describe authentication of outgoing mail. Before making changes, export or note the existing records and plan a verification step after DNS propagation.

Understand the two sender identities in a message

An email has the sender visible in From and an identity used during SMTP delivery, often called the envelope sender or Return-Path. They can differ. The first is what the reader associates with the company; the second is involved in the SPF check and in handling non-delivery notices.

This distinction explains why a message can pass SPF without passing DMARC. For example, an external service may send with its own authenticated Return-Path while From shows the company's domain. SPF passes for the service's domain, but that does not necessarily prove that the domain is aligned with From. In that case, a correct, aligned DKIM signature can allow DMARC to pass.

Configure SPF around real sending activity

SPF is a TXT record published for the domain being checked. It begins with v=spf1 and contains mechanisms describing permitted sources, followed by a final rule. A purely illustrative example is v=spf1 ip4:192.0.2.10 -all: that address belongs to a range reserved for documentation and must not be copied into a real configuration.

If mail leaves through a provider, follow that provider's official instructions, which may include an include mechanism. If messages also leave through a company server, both sources must be considered. A final -all indicates that other sources are not authorized; ~all produces a softfail result. The choice depends on how complete the inventory and testing are, not on an aesthetic preference.

Keep one coherent SPF record for each DNS name

Having two providers is not solved by adding two separate records beginning with v=spf1 at the same DNS name. The specification treats multiple selected SPF records for the same name as a permanent error. Build one policy that includes all legitimate sources, while checking that it does not inadvertently authorize unnecessary systems.

When a service offers a ready-to-paste string, compare it with the existing record. Replacing the latter in full could break authentication for another sender. It helps to keep brief documentation alongside the record: who requested each mechanism, which application it serves and when it was last verified. The SPF specification describes what happens when there are multiple records.

Check DNS lookups and SPF complexity

The include, a, mx, ptr and exists mechanisms, and the redirect modifier, can require DNS queries during SPF evaluation. The specification sets an overall limit of ten terms that cause such queries; exceeding it produces permerror. Adding providers without measuring the chain of includes may therefore make mail authentication worse rather than protect it.

Count the lookups in the actual evaluation, including nested includes, not merely the words visible in the main record. ip4, ip6 and all do not consume that limit. A short, documented and current policy is preferable to a long list of services that are no longer used. Avoid overly broad mechanisms that authorize addresses outside the company simply to make a test pass.

Enable DKIM for every service that signs mail

DKIM is configured in the system that sends or relays outgoing mail and in the signing domain's DNS. The service generates or manages a private key used to sign the message; the corresponding public key is published in DNS. The recipient can check that the signed parts were not altered in transit.

Never copy a private key into DNS or send it by email. With managed services, the administration panel generally supplies the name and value of the record to publish and then requires signing to be enabled. In some cases the provider offers a CNAME instead of a directly managed TXT record: follow the documented procedure for that platform, without mixing instructions for different systems.

Understand the selector and signing domain

A DKIM signature contains a domain identified by the d= parameter and a selector identified by s=. The public key is looked up under a name composed of the selector, _domainkey and the signing domain. As a demonstration, if the selector is posta1 and the domain is example.com, the name is posta1._domainkey.example.com.

Selectors allow several keys to be used and rotated without turning off all signatures at once. When several providers send for the same domain, they can use separate selectors. For DMARC, the domain in d= also matters: a valid signature for an unrelated domain may be useful to the provider, but it is not necessarily aligned with the company's From domain. The DKIM specification describes this mechanism.

Choose suitable keys and verify the signature

Key length depends on the capabilities of the service and DNS control panel. For RSA keys, the update to the standard requires signers to use at least 1024 bits and recommends 2048 bits; where supported by the provider and DNS, 2048 bits is a suitable choice. RFC 8301 specifies these values.

After publishing the record, enable signing in the service's panel and send test messages to external recipients. Look for DKIM=pass in the headers and check the d= domain. If the test fails, check the record name, the complete key value, the selector actually in use and any changes to the message introduced by gateways or signatures added along the way.

Understand the DMARC check

DMARC evaluates the domain in the visible From field. A message passes DMARC if SPF passes and is aligned with that domain, or if DKIM passes and is aligned; both do not have to pass in the same message. The distinction between passing authentication and alignment is essential: a system can perfectly authenticate its own domain without authenticating the one the reader sees.

The DMARC record also lets the domain owner request how messages that fail the check should be handled and where aggregate reports should be sent. It is a request to recipients, not an absolute guarantee of delivery or rejection: receiving systems retain their own rules. The DMARC specification explains this relationship.

Relaxed and strict alignment

With relaxed alignment, the authenticated domain and the one in From must share the organizational domain; with strict alignment, they must match exactly. For example, a signature for example.com and a From address at news.example.com can align in relaxed mode but not in strict mode. DMARC normally uses relaxed mode unless another setting is specified.

The adkim and aspf parameters allow the mode to be chosen separately for DKIM and SPF. Before selecting strict mode, check subdomains used by newsletters, transactional platforms and external services. An otherwise legitimate difference between names could cause unexpected failures. The right choice depends on the actual architecture, not on an assumption that stricter is always better.

Publish an initial DMARC record for observation

DMARC is published as a TXT record under the domain's _dmarc name. A demonstration example is v=DMARC1; p=none; rua=mailto:dmarc@example.com. The p=none tag asks for no specific rejection or quarantine action based on the DMARC policy, while allowing results to be observed. The reporting address must be a genuinely managed mailbox able to receive aggregate data.

Do not copy example.com, specify a nonexistent mailbox or treat the existence of the record alone as proof that the system works. Some providers require extra steps to receive reports for other domains; others do not send reports. After publication, check the authoritative DNS record and send messages from every inventoried source, examining the results in recipients' headers.

Move from observation to quarantine and rejection

The main DMARC policies are p=none, p=quarantine and p=reject. The first is for observation; the second asks recipients to treat nonconforming messages as suspicious; the third asks them to reject those messages. It is unwise to move to reject until applications, newsletters and occasional sending sources have been tested.

A reasonable progression is to collect reports, correct legitimate sources that are not aligned, try a more restrictive policy and observe the effects before proceeding. The time required depends on sending volume and diversity: there is no universal number of days. If genuine messages start being rejected, address the source or pause the move to a stricter policy until the flow is understood.

Read reports without mistaking them for a list of people

Aggregate DMARC reports show information about flows observed by the recipients that produce them: sending sources, authentication results and actions taken. They help reveal a forgotten service, an incorrect configuration or traffic impersonating the domain. They are not a complete list of every individual email the company has sent, and coverage depends on the recipients that generate them.

An unknown volume does not automatically prove an attack: it may come from a legitimate application, a forwarder or a service missing from the inventory. Verify who manages a source before authorizing it. Reports can contain sensitive operational information; store them with appropriate access controls and defined retention periods. The DMARC RFC describes their purpose and contents.

Manage multiple providers without losing alignment

A company may use one suite for ordinary email, a platform for newsletters and a service for website notifications. Consider each channel separately. The newsletter provider might require a dedicated subdomain and its own DKIM signature; the website might need to send through authenticated SMTP rather than using the web server as a direct sender.

For each channel, check From, Return-Path and the actual signature. A provider's claim that “SPF is active” is not enough if the check concerns only its own domain and the company's From domain is not aligned. If a platform cannot provide SPF alignment, an aligned DKIM signature may be sufficient, provided it is stable and verified. Documenting the contact responsible for each service makes future changes easier.

Account for forwarding, lists and message changes

Traditional forwarding can cause mail to reach a recipient from a server other than one authorized by the original domain; SPF may therefore fail at the final destination. DKIM can continue to work if the signed content is not changed, but some lists and gateways alter the subject, body or headers and may invalidate the signature. These cases explain why real-world results do not always match a direct test.

When investigating a failure, reconstruct the route: initial send, any forwarding, gateway, list and final recipient. Do not indiscriminately add forwarding servers' addresses to your domain's SPF record: they are often outside the company's control. The solution depends on the intermediate system and may require provider-specific settings or a different sending flow.

Verify results with independent recipients

The best check combines DNS queries with real messages. First confirm that the published records are visible externally; then send an email from every inventoried system to test mailboxes at different recipient providers. For each message, examine the headers and authentication results, paying attention to the domain that was actually verified.

A minimum checklist includes:

  • There is only one SPF record at the intended name and it does not produce permerror.
  • The DKIM signature is present and verifies correctly with the right selector.
  • At least one of SPF and DKIM passes and is aligned with From for DMARC.
  • Newsletters, forms, business applications and occasional sends have been tested.
  • DMARC reports arrive at the intended mailbox and are reviewed.

A display that says only “authenticated” can hide the most important detail: which domain was authenticated. Keeping a few test messages and their results makes it easier to compare the situation after a provider change.

Resolve the most common errors

If SPF returns permerror, check for multiple records, syntax problems and the number of lookups. If it returns fail for legitimate mail, verify the outgoing server's IP address and the domain used for the envelope sender. If DKIM is absent, signing may not be enabled in the service; if verification fails, check the selector, DNS key and modifications to the message.

If SPF and DKIM both pass but DMARC fails, inspect alignment with From. You may need to configure a custom domain in the external service, rather than add more addresses to SPF. If a message is still classified as spam, remember that authentication and reputation are different assessments: content, sending behavior and the recipient's rules continue to matter. Avoid hasty fixes without a repeatable test.

Maintain the configuration over time

Authentication is not a one-time intervention. A new CRM, a change of newsletter platform or an email migration changes the authorized sending sources. Every new service should enter the inventory before it sends from the business domain; every retired service should be removed after confirming that it no longer produces traffic.

Plan periodic checks of records, DMARC reports, signature validity and permissions in the DNS panel. DKIM keys should be managed and rotated according to the provider's capabilities and company procedures. Keeping track of who can change DNS and sending platforms reduces errors and unauthorized changes. A short but current register is worth more than a complex undocumented configuration.

Frequently asked questions

Is SPF enough to protect the domain?

No. SPF checks a particular identity in SMTP delivery and may not be aligned with the visible From. DKIM and DMARC add signature verification and the relationship with the domain shown to the reader. For coherent protection, configure and test all three in accordance with actual mail flows.

Can I publish p=reject immediately?

Technically yes, but without a reliable inventory you could also affect genuine messages. An observation phase using p=none and analyzed reports helps identify unaligned sending sources. The move to more restrictive policies should be decided from the results, not merely because the record exists.

Do SPF, DKIM and DMARC guarantee inbox placement?

No. Authentication is only part of the assessment performed by recipients. Domain and IP reputation, message quality, sending behavior and local policies can all influence delivery. The Gmail sender guidelines distinguish authentication requirements from additional guidance.

Must I configure subdomains separately?

It depends on how they are used for sending, existing records and the main domain's DMARC policy. A subdomain dedicated to newsletters or notifications can have its own SPF and DKIM and, if needed, a specific DMARC policy. Check the names actually used in messages before adding records or applying a rule to subdomains.

Conclusion: a configuration that follows real mail flows

SPF, DKIM and DMARC work best when they reflect the actual structure of business email. The process starts with a sender inventory, continues with correct DNS records and active signatures, and is completed through tests, reports and maintenance. The strictest policy has value only if legitimate messages are reliably recognized.

Whoever manages the domain should be able to answer three simple questions: which services send, with which domain they authenticate and how an error is discovered before it becomes a problem for customers and colleagues. Documenting those answers turns three technical acronyms into a practical measure of continuity and trust.

Would you like to explore this topic for your business? Azienda Digitale can help you assess the right solutions and put them into practice. Azienda Digitale

Lascia un commento

Your email address will not be published. Required fields are marked *

Your comment will be visible after approval by the administrator.

Il commento sara visibile dopo approvazione dell amministratore.