Email authentication is the process of verifying the identity of an email sender and ensuring that the email has not been tampered with during transmission. As a developer, it is essential to understand the different email authentication methods and implement them correctly to prevent email fraud and increase email deliverability. In this blog, we’ll explore the different email authentication methods and how to implement them as a developer.
Why Email Authentication is Important?
Email authentication for developers is a process that ensures emails sent from your domain are legitimate. Let’s check out the top 5 reasons to invest in these protocols:
1. Improved Inbox Placement
Email authentication establishes domain trust with receiving mailboxes, drastically decreasing the probability of your emails being routed to the spam folder.
2. Preserving Sending Reputation
Authenticating outbound traffic prevents bad actors from high-jacking your domain name to send spam, shielding your domain from getting listed on global RBLs (Real-time Blackhole Lists).
3. Reduced Spam Complaints
Implementing these protocols makes it much harder for spoofers to mimic your brand. Authentic messages pass validation, significantly lowering the rate of legitimate recipients marking forged messages as spam.
Simplify Email Authentication with PowerDMARC!
Implementing and maintaining reliable email authentication protocols may require experienced technical specialists. Companies can hire remote developers with the relevant expertise to help configure authentication standards, or use a managed service provider.
Related read: Email Verification
What is SPF?
Email authentication for developers starts with the understanding and implementation of SPF or Sender Policy Framework. This protocol works by asking you to create and update a list of servers permitted to send emails using your domain name. The list is added to the DNS server from where the receivers’ servers verify if a sender’s server is part of the list or not. The result for an unlisted IP depends on the qualifier of the final all: -all gives fail, ~all softfail, ?all neutral. If there is no all and no redirect, the default is neutral.
The best C# developers understand the importance of SPF email authentication and can implement it to ensure secure and reliable email communication.
All this requires an SPF record which is a TXT record that lets administrators enter arbitrary texts into DNS.
What are SPF Record Tags?
| Tag | Purpose |
| Version (v) | It represents the SPF versions and must be inserted first in an SPF record. |
| mx | The mx mechanism in a SPF record authorizes the mail servers listed in a domain’s DNS Mail Exchange (MX) records to send email on behalf of that domain. |
| a | It’s used when you query for an A or AAAA record in a domain having the sender’s IP address. |
| ptr | Ptr does a reverse DNS lookup on the sending IP and validates the returned names. This tag is NOT recommended to be used per RFC 7208. |
| ip4 | It tells an IPv4 IP address or IP CIDR Range that is allowed to send mail from your domain. |
| ip6 | It tells an IPv6 IP address or IP CIDR Range permitted to send emails from your domain |
| include | The SPF include mechanism triggers a recursive lookup of the target domain’s SPF record. It evaluates the sender’s IP against that target record: if the nested evaluation returns Pass, the include mechanism matches and returns Pass to the parent record. If it returns any other result (Fail, SoftFail, Neutral, etc.) or fails to match, the include mechanism does not match, and the parent record continues evaluating its subsequent mechanisms. |
| exists | The SPF exists mechanism performs an IPv4 address (A) record lookup on the specified domain name. If the DNS query returns any valid A record (regardless of the specific IP address returned), the mechanism matches. The evaluation result is determined by the mechanism’s qualifier (returning Pass only if the default + qualifier is used). Crucially, the validator performs an A record query even if the incoming SMTP connection is over IPv6. |
| all | The SPF all mechanism is placed at the end of an SPF record. It specifies how receiving servers should evaluate emails sent from IP addresses that did NOT match any of previous mechanisms. The three primary qualifiers dictate the evaluation result:
|
Limitations and Challenges of SPF
SPF isn’t sufficient to combat all types of phishing and spamming attacks attempted in your company’s name. So, while learning about email authentication for developers, you need to focus on understanding the limitations of SPF limitations.
There’s a 10-lookup limit enforced by the receiving SPF verifier to avoid overloading validator resources like CPU and bandwidth. Once this limit is exceeded, it triggers an SPF Permerror. The limit counts evaluated terms that require DNS queries: the include, a, mx, ptr, and exists mechanisms, as well as the redirect modifier. SPF also specifies a SHOULD limit of 2 void lookups per evaluation (separate from the general 10 DNS lookup limit), which similarly results in a Permerror if exceeded.
You can stay within the 10 DNS lookup limit for SPF by:
- Removing unused services
- Avoiding the use of ptr mechanism
- Avoiding the use of mx mechanism
- Using IPv6 or IPv4
- Flattening your SPF record
SPF records are evaluated against the SMTP envelope MAIL FROM identity (the envelope sender) and the HELO / EHLO domain—never the user-visible From: header. For DMARC alignment, receiving servers evaluate only the SPF result of the MAIL FROM domain against the domain found in the From: header.
What is DKIM?
DKIM stands for DomainKeys Identified Mail, and is a protocol that authenticates emails using cryptographic signature. The signer generates the key pair and keeps the private key. The public key is then published in DNS under a selector, and verifiers retrieve it from there. Signatures survive only if relays don’t change the signed content. Plain relays generally preserve them; however, intermediaries that modify messages break them.
What are DKIM Tags?
There are many informal elements as part of the DKIM tag cluster. These are classified as required and optional tags. We’re discussing the uses of required tags here; click here to learn about other tags in detail.
Required Tags
- v= The version tag that represents the DKIM standard being used. Its value is always set to 1.
- a= This DKIM tag represents the cryptographic algorithm used for creating the signature. Signers must sign with rsa-sha256, and rsa-sha1 must not be used for signing or verifying. RFC 6376 originally only said signers should use rsa-sha256. RFC 8463 adds ed25519-sha256.
- s= this tag specifies the selector record name used for finding the public key in a domain’s DNS. Domain administrators or app developers have to enter a name or a number in this field.
- d= You can see the domain used with the selector record to locate public keys. It can be any valid DNS name where the key record is published.
- b= this is the signature data (base64). It covers the header fields listed in h= plus the DKIM-Signature header itself, which includes bh=.
- bh= is the hash of the canonicalized body only, limited by l= if present.
- h= is a colon-separated list of signed header field names. It must not be empty and must include From. Changing a signed header in transit breaks verification.
Note: A signature missing a required tag is ignored and returns permanent verification failure; the message isn’t rejected. Verification failure “does not force rejection.” Consumers should not decide acceptability solely on an unverifiable signature.
Limitations and Challenges of DKIM
Legitimate emails sent from your domain can occasionally fail authentication if an intermediate forwarding server modifies the message content (such as appending a footer) in transit.
The receiving server performs the verification. If the signature is broken by these modifications, the receiving server treats the email as unsigned (unauthenticated) rather than active proof of forgery, meaning it does not automatically force a rejection.
What is DMARC?
The last leg of the understanding of email authentication for developers is learning about DMARC or Domain-based Message Authentication, Reporting, and Conformance. It works in alignment with SPF and/or DKIM results to decide how to deal with emails failing email authentication checks. You can choose to set your DMARC policy to p=none (no action is taken against the failed emails), p=quarantine (means the domain owner considers failing mail suspicious), or p=reject (the domain owner requests the mail to be rejected, the final call depends on the receiver’s local policy).
You can start by setting your policy to ‘none’ to monitor if all legitimate emails are passing the verification checks. Later, you can reset it to ‘quarantine’ or ‘reject’.
What are DMARC Tags?
As a domain owner, you can specify the following DMARC tags in your DMARC record-
- v: It denotes the DMARC protocol version and always has the value v=DMARC1.
- pct: Under RFC 7489, pct applied the DMARC policy to a percentage of failing messages. RFC 9989 removed it and replaced part of its function with t (t=y / t=n).
- p: The p tag addresses the DMARC policy mode. You can select from reject, quarantine, and none.
- rua: This optional tag indicates the email address where reporting organizations can send their DMARC aggregate data.
- ruf: It tells the address to which the DMARC forensic ruf report is to be sent.
- fo: it’s an optional tag that caters to the available failure/forensic reporting options domain owners can choose from.
- aspf: It lets you set the SPF alignment mode. The value can be either strict(s) or relaxed(r)
- adkim: It lets you set the DKIM alignment mode, the value of which can be either strict(s) or relaxed(r)
- rf: Forensic reporting format. Removed in RFC 9989.
- ri: This optional DMARC tag had a default value of 86400, and it told the time interval in seconds between two consecutive aggregate reports sent by the reporting organization to the domain owner. Removed in RFC 9989.
Final Words
Email authentication for developers is critical to stay abreast of phishing and spamming attacks attempted in your name. Start by generating SPF, DKIM, and DMARC records for your official email-sending domain using our PowerToolbox.


