Authenticating domains with SPF and DKIM
Email authentication verifies that emails sent from your domain are legitimate. SPF and DKIM are two protocols that work together to prevent spoofing, protect your brand, and improve deliverability.
Why authenticate your domain¶
Authenticating your domain provides two key benefits:
- Brand protection: SPF and DKIM verify that emails come from authorised servers, making it harder for attackers to impersonate your domain in phishing or spoofing attempts.
- Improved deliverability: mailbox providers use SPF and DKIM to assess incoming emails. Authenticated emails are more likely to reach the inbox instead of being flagged as spam.
SPF¶
SPF (Sender Policy Framework) is an email authentication protocol that lets you specify which mail servers can send email on behalf of your domain. It works by publishing a DNS TXT record in your domain's DNS settings.
Note
If you can't locate or access your DNS records, contact your domain hosting provider for guidance.
How SPF works¶
When you send an email, the receiving server checks your SPF record to confirm the email came from an authorised IP address or hostname. If the sending server matches an entry in the record, the email passes SPF authentication.
The include:spf.mailjet.com directive tells recipient servers that Apteco Email's servers are authorised to send on behalf of your domain. The ~all qualifier at the end means that any server not listed in the record is treated as suspicious, but not outright rejected.
SPF qualifiers¶
The qualifier at the end of your SPF record controls how receiving servers handle unauthorised senders:
| Qualifier | Syntax | Behaviour |
|---|---|---|
| SoftFail | ~all |
Unauthorised servers are marked as suspicious but still accepted |
| HardFail | -all |
Unauthorised servers are rejected outright |
| Neutral | ?all |
No positive or negative bias is applied to unlisted servers |
Choose a qualifier based on your risk tolerance. SoftFail (~all) is recommended when you're first setting up SPF, as it lets you monitor results before enforcing stricter policies.
Configuring SPF¶
Once Apteco finishes setting up your domain, you'll receive the DNS records you need to add to your domain settings.
Warning
You can only have one SPF record per domain. If a record already exists, you must modify it to include the new entry rather than adding a separate record.
To create or update your SPF record:
- Open your DNS management console.
- Locate the existing TXT record for your domain, or create a new one.
- Set the record value to include all authorised sending sources.
Multiple sending sources
Merging multiple SPF records¶
If your domain already has an SPF record and you need to add Apteco Email, consolidate both into a single record. Having two separate SPF records for the same domain causes conflicts and authentication failures.
Before merging (incorrect):
After merging (correct):
DKIM¶
DKIM (DomainKeys Identified Mail) adds a digital signature to your outgoing email messages. The receiving server uses this signature to verify that the email content hasn't been altered in transit, and that it was sent from an authorised domain.
Note
If you can't locate or access your DNS records, contact your domain hosting provider for guidance.
How DKIM works¶
DKIM uses public-private key encryption. When you send an email, Apteco Email signs it with a private key. The recipient's server then verifies the signature using the corresponding public key, which is published as a TXT record in your domain's DNS. If the signatures match, the email is confirmed as legitimate and unaltered.
Configuring DKIM¶
Once Apteco finishes setting up your domain, you'll receive the DNS records you need to add for DKIM.
When adding the record:
- Some domain providers require the entire TXT value to be enclosed in double quotes. If you're unsure, consult your provider's support documentation.
- Some providers automatically append the domain name to the Host field value. Check the Host field after saving to confirm the entry is correct.
DMARC¶
SPF and DKIM verify whether an email comes from a trusted source, but only DMARC (Domain-based Message Authentication, Reporting and Conformance) can enforce policies that prevent spoofed emails from being delivered. Implementing all three protocols provides a comprehensive email authentication framework.
A DMARC record lets you:
- Set policies for how receiving servers handle emails that fail SPF or DKIM checks
- Receive reports on email activity, failed authentication checks, and potential domain abuse
To fully protect your domain and recipients from email spoofing, implement DMARC after configuring SPF and DKIM.
Best practices¶
To maintain effective email authentication:
- Use DMARC alongside SPF and DKIM: DMARC acts as the control mechanism that enforces your authentication policies and provides visibility into how your domain is being used.
- Monitor DMARC reports regularly: review reports to identify failed SPF or DKIM checks and detect any unauthorised use of your domain.
- Keep DNS records consistent: ensure all domains used for sending email have up-to-date SPF, DKIM, and DMARC records. Inconsistent records can reduce deliverability and cause emails to be marked as spam.
- Review and update your SPF record: as your email infrastructure changes, update your SPF record to add new sources or remove obsolete ones.
Troubleshooting¶
DNS propagation¶
DNS changes can take anywhere from a few minutes to 48 hours to propagate. Verify your SPF and DKIM setup after allowing sufficient time for propagation.
SPF issues¶
| Issue | Details |
|---|---|
| Multiple SPF records | You can only have one SPF record per domain. If multiple records exist, consolidate them into a single record. |
| SPF record type | SPF must be published as a TXT record. Although an SPF record type exists, it isn't recommended and shouldn't be used. |
| SPF record too long | SPF records are limited to 10 DNS lookups. If you exceed this limit, you'll encounter errors such as too many DNS lookups or permerror. To resolve this, consolidate records or use subdomains for different services. |
| 10-lookup limit behaviour | Validators evaluate SPF records sequentially and stop when they find a match. Depending on the sender, a validator may not reach the 10-lookup limit even if the full policy requires more lookups. This can make SPF-related delivery issues difficult to diagnose. |
DKIM issues¶
| Issue | Details |
|---|---|
| DKIM not authenticating | Confirm that the TXT record is configured exactly as provided by Apteco, with no additional spaces or characters. |
| DKIM record type | DKIM is published as a TXT record in your DNS. It contains the public key used to verify that messages were authorised by the domain owner. |
General issues¶
| Issue | Details |
|---|---|
| Email rejected despite correct setup | Some receiving servers apply additional authentication checks. Implementing SPF, DKIM, and DMARC together provides the most comprehensive coverage. |