7Internet Engineering Task Force (IETF) S. Kitterman
8Request for Comments: 7208 Kitterman Technical Services
9Obsoletes: 4408 April 2014
10Category: Standards Track
14 Sender Policy Framework (SPF)
15 for Authorizing Use of Domains in Email, Version 1
19 Email on the Internet can be forged in a number of ways. In
20 particular, existing protocols place no restriction on what a sending
21 host can use as the "MAIL FROM" of a message or the domain given on
22 the SMTP HELO/EHLO commands. This document describes version 1 of
23 the Sender Policy Framework (SPF) protocol, whereby ADministrative
24 Management Domains (ADMDs) can explicitly authorize the hosts that
25 are allowed to use their domain names, and a receiving host can check
28 This document obsoletes RFC 4408.
32 This is an Internet Standards Track document.
34 This document is a product of the Internet Engineering Task Force
35 (IETF). It represents the consensus of the IETF community. It has
36 received public review and has been approved for publication by the
37 Internet Engineering Steering Group (IESG). Further information on
38 Internet Standards is available in Section 2 of RFC 5741.
40 Information about the current status of this document, any errata,
41 and how to provide feedback on it may be obtained at
42 http://www.rfc-editor.org/info/rfc7208.
58Kitterman Standards Track [Page 1]
60RFC 7208 Sender Policy Framework (SPF) April 2014
65 Copyright (c) 2014 IETF Trust and the persons identified as the
66 document authors. All rights reserved.
68 This document is subject to BCP 78 and the IETF Trust's Legal
69 Provisions Relating to IETF Documents
70 (http://trustee.ietf.org/license-info) in effect on the date of
71 publication of this document. Please review these documents
72 carefully, as they describe your rights and restrictions with respect
73 to this document. Code Components extracted from this document must
74 include Simplified BSD License text as described in Section 4.e of
75 the Trust Legal Provisions and are provided without warranty as
76 described in the Simplified BSD License.
78 This document may contain material from IETF Documents or IETF
79 Contributions published or made publicly available before November
80 10, 2008. The person(s) controlling the copyright in some of this
81 material may not have granted the IETF Trust the right to allow
82 modifications of such material outside the IETF Standards Process.
83 Without obtaining an adequate license from the person(s) controlling
84 the copyright in such materials, this document may not be modified
85 outside the IETF Standards Process, and derivative works of it may
86 not be created outside the IETF Standards Process, except to format
87 it for publication as an RFC or to translate it into languages other
92 1. Introduction ....................................................5
93 1.1. Terminology ................................................5
94 1.1.1. Key Words ...........................................5
95 1.1.2. Imported Definitions ................................5
96 1.1.3. MAIL FROM Definition ................................6
97 1.1.4. HELO Definition .....................................6
98 1.2. check_host() ...............................................6
99 2. Operational Overview ............................................6
100 2.1. Publishing Authorization ...................................6
101 2.2. Checking Authorization .....................................7
102 2.3. The "HELO" Identity ........................................8
103 2.4. The "MAIL FROM" Identity ...................................9
104 2.5. Location of Checks .........................................9
105 2.6. Results of Evaluation ......................................9
106 2.6.1. None ...............................................10
107 2.6.2. Neutral ............................................10
108 2.6.3. Pass ...............................................10
109 2.6.4. Fail ...............................................10
114Kitterman Standards Track [Page 2]
116RFC 7208 Sender Policy Framework (SPF) April 2014
119 2.6.5. Softfail ...........................................10
120 2.6.6. Temperror ..........................................10
121 2.6.7. Permerror ..........................................10
122 3. SPF Records ....................................................11
123 3.1. DNS Resource Records ......................................11
124 3.2. Multiple DNS Records ......................................12
125 3.3. Multiple Strings in a Single DNS Record ...................12
126 3.4. Record Size ...............................................13
127 3.5. Wildcard Records ..........................................13
128 4. The check_host() Function ......................................14
129 4.1. Arguments .................................................14
130 4.2. Results ...................................................15
131 4.3. Initial Processing ........................................15
132 4.4. Record Lookup .............................................15
133 4.5. Selecting Records .........................................15
134 4.6. Record Evaluation .........................................16
135 4.6.1. Term Evaluation ....................................16
136 4.6.2. Mechanisms .........................................16
137 4.6.3. Modifiers ..........................................17
138 4.6.4. DNS Lookup Limits ..................................17
139 4.7. Default Result ............................................18
140 4.8. Domain Specification ......................................19
141 5. Mechanism Definitions ..........................................20
142 5.1. "all" .....................................................21
143 5.2. "include" .................................................21
144 5.3. "a" .......................................................23
145 5.4. "mx" ......................................................23
146 5.5. "ptr" (do not use) ........................................23
147 5.6. "ip4" and "ip6" ...........................................25
148 5.7. "exists" ..................................................25
149 6. Modifier Definitions ...........................................26
150 6.1. redirect: Redirected Query ................................26
151 6.2. exp: Explanation ..........................................27
152 7. Macros .........................................................28
153 7.1. Formal Specification ......................................29
154 7.2. Macro Definitions .........................................29
155 7.3. Macro Processing Details ..................................30
156 7.4. Expansion Examples ........................................32
157 8. Result Handling ................................................33
158 8.1. None ......................................................34
159 8.2. Neutral ...................................................34
160 8.3. Pass ......................................................34
161 8.4. Fail ......................................................35
162 8.5. Softfail ..................................................35
163 8.6. Temperror .................................................36
164 8.7. Permerror .................................................36
170Kitterman Standards Track [Page 3]
172RFC 7208 Sender Policy Framework (SPF) April 2014
175 9. Recording the Result ...........................................36
176 9.1. The Received-SPF Header Field .............................37
177 9.2. SPF Results in the Authentication-Results Header Field ....39
178 10. Effects on Infrastructure .....................................39
179 10.1. Sending Domains ..........................................40
180 10.1.1. DNS Resource Considerations .......................40
181 10.1.2. Administrator's Considerations ....................41
182 10.1.3. Bounces ...........................................41
183 10.2. Receivers ................................................42
184 10.3. Mediators ................................................42
185 11. Security Considerations .......................................43
186 11.1. Processing Limits ........................................43
187 11.2. SPF-Authorized Email May Contain Other False Identities ..44
188 11.3. Spoofed DNS and IP Data ..................................44
189 11.4. Cross-User Forgery .......................................44
190 11.5. Untrusted Information Sources ............................45
191 11.5.1. Recorded Results ..................................45
192 11.5.2. External Explanations .............................45
193 11.5.3. Macro Expansion ...................................46
194 11.6. Privacy Exposure .........................................46
195 11.7. Delivering Mail Producing a "Fail" Result ................46
196 12. Collected ABNF ................................................46
197 13. Contributors and Acknowledgements .............................48
198 14. IANA Considerations ...........................................49
199 14.1. The SPF DNS Record Type ..................................49
200 14.2. The Received-SPF Mail Header Field .......................50
201 14.3. SPF Modifier Registry ....................................50
202 15. References ....................................................50
203 15.1. Normative References .....................................50
204 15.2. Informative References ...................................51
205 Appendix A. Extended Examples .....................................54
206 A.1. Simple Examples ............................................55
207 A.2. Multiple Domain Example ....................................56
208 A.3. DNS Blacklist (DNSBL) Style Example ........................56
209 A.4. Multiple Requirements Example ..............................57
210 Appendix B. Changes in Implementation Requirements from RFC 4408 ..57
211 Appendix C. Further Testing Advice ................................58
212 Appendix D. SPF/Mediator Interactions .............................59
213 D.1. Originating ADMDs ..........................................59
214 D.2. Mediators ..................................................60
215 D.3. Receiving ADMDs ............................................60
216 Appendix E. Mail Services .........................................61
217 Appendix F. MTA Relays ............................................61
218 Appendix G. Local Policy Considerations ...........................62
219 G.1. Policy for SPF Pass ........................................62
220 G.2. Policy for SPF Fail ........................................62
221 G.3. Policy for SPF Permerror ...................................63
222 G.4. Policy for SPF Temperror ...................................63
226Kitterman Standards Track [Page 4]
228RFC 7208 Sender Policy Framework (SPF) April 2014
233 The current email infrastructure has the property that any host
234 injecting mail into the system can use any DNS domain name it wants
235 in each of the various identifiers specified by [RFC5321] and
236 [RFC5322]. Although this feature is desirable in some circumstances,
237 it is a major obstacle to reducing Unsolicited Bulk Email (UBE, aka
238 spam). Furthermore, ADMDs (as described in [RFC5598]) are
239 understandably concerned about the ease with which other entities can
240 make use of their domain names, often with malicious intent.
242 This document defines a protocol by which ADMDs can authorize hosts
243 to use their domain names in the "MAIL FROM" or "HELO" identities.
244 Compliant ADMDs publish Sender Policy Framework (SPF) records in the
245 DNS specifying which hosts are permitted to use their names, and
246 compliant mail receivers use the published SPF records to test the
247 authorization of sending Mail Transfer Agents (MTAs) using a given
248 "HELO" or "MAIL FROM" identity during a mail transaction.
250 An additional benefit to mail receivers is that after the use of an
251 identity is verified, local policy decisions about the mail can be
252 made based on the sender's domain, rather than the host's IP address.
253 This is advantageous because reputation of domain names is likely to
254 be more accurate than reputation of host IP addresses since domains
255 are likely to be more stable over a longer period. Furthermore, if a
256 claimed identity fails verification, local policy can take stronger
257 action against such email, such as rejecting it.
263 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
264 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
265 "OPTIONAL" in this document are to be interpreted as described in
2681.1.2. Imported Definitions
270 ABNF (Augmented Backus-Naur Form) ABNF is defined in [RFC5234], as
271 are the tokens "ALPHA", "DIGIT", and "SP" (space).
273 The tokens "Local-part", "Domain", and "Mailbox" are defined in
276 "dot-atom", "quoted-string", "comment", "CFWS" (comment folded white
277 space), "FWS" (folded white space), and "CRLF" (carriage-return/
278 line-feed) are defined in [RFC5322].
282Kitterman Standards Track [Page 5]
284RFC 7208 Sender Policy Framework (SPF) April 2014
2871.1.3. MAIL FROM Definition
289 This document is concerned with the identity of the sender of a mail
290 message, as referred to in [RFC5321]:
292 The transaction starts with a MAIL command that gives the sender
295 Since there are many other names for this identity, it is important
296 to choose a name that is:
302 As such, throughout this document the term "MAIL FROM" will be used,
303 which is defined as the RFC5321.MailFrom (reverse-path) identity
304 described in [RFC5598].
3061.1.4. HELO Definition
308 This document also makes use of the HELO/EHLO identity. The "HELO"
309 identity derives from either the SMTP HELO or EHLO command (see
310 [RFC5321]). Since HELO and EHLO can, in many cases, be used
311 interchangeably, they are identified commonly as "HELO" in this
312 document. This means RFC5321.HELO/.EHLO as defined in [RFC5598].
313 These commands supply the identity of the SMTP client (sending host)
314 for the SMTP session.
318 Section 4 introduces an algorithm to evaluate an SPF policy against
319 an arriving email transaction. In an early implementation, this
320 algorithm was encoded in a function called check_host(). That name
321 is used in this document as symbolic of the SPF evaluation algorithm,
322 but of course implementers are not required to use this name.
3242. Operational Overview
3262.1. Publishing Authorization
328 An SPF-compliant domain publishes valid SPF records as described in
329 Section 3. These records authorize the use of the relevant domain
330 names in the "HELO" and "MAIL FROM" identities by the MTAs specified
338Kitterman Standards Track [Page 6]
340RFC 7208 Sender Policy Framework (SPF) April 2014
343 SPF results can be used to make both positive (source is authorized)
344 and negative (source is not authorized) determinations. If ADMDs
345 choose to publish SPF records and want to support receivers making
346 negative authorization determinations, it is necessary for them to
347 publish records that end in "-all", or redirect to other records that
348 do; otherwise, no definitive determination of authorization can be
349 made. Potential issues and mitigations associated with negative
350 determinations are discussed in Section 10.
352 ADMDs that wish to declare that no hosts are authorized to use their
353 DNS domain names in the HELO or MAIL FROM commands during SMTP
354 sessions can publish SPF records that say so for domain names that
355 are neither used in the domain part of email addresses nor expected
358 When changing SPF records, care has to be taken to ensure that there
359 is a transition period so that the old policy remains valid until all
360 legitimate email can reasonably expect to have been checked.
361 [RFC5321], Section 4.5.4.1 discusses how long a message might be in
362 transit. While offline checks are possible, the closer to the
363 original transmission time checks are performed, the more likely they
364 are to get an SPF result that matches the sending ADMD intent at the
365 time the message was sent.
3672.2. Checking Authorization
369 A mail receiver can perform a set of SPF checks for each mail message
370 it receives. An SPF check tests the authorization of a client host
371 to emit mail with a given identity. Typically, such checks are done
372 by a receiving MTA, but can be performed elsewhere in the mail
373 processing chain so long as the required information is available and
374 reliable. The "MAIL FROM" and "HELO" identities are checked as
375 described in Sections 2.4 and 2.3, respectively.
377 Without explicit approval of the publishing ADMD, checking other
378 identities against SPF version 1 records is NOT RECOMMENDED because
379 there are cases that are known to give incorrect results. For
380 example, almost all mailing lists rewrite the "MAIL FROM" identity
381 (see Section 10.3), but some do not change any other identities in
382 the message. Documents that define other identities will have to
383 define the method for explicit approval.
385 It is possible that mail receivers will use the SPF check as part of
386 a larger set of tests on incoming mail. The results of other tests
387 might influence whether or not a particular SPF check is performed.
388 For example, finding the sending host's IP address on a local
389 whitelist might cause all other tests to be skipped and all mail from
390 that host to be accepted.
394Kitterman Standards Track [Page 7]
396RFC 7208 Sender Policy Framework (SPF) April 2014
399 When a mail receiver decides to perform an SPF check, it has to use a
400 correctly implemented check_host() function (Section 4) evaluated
401 with the correct parameters. Although the test as a whole is
402 optional, once it has been decided to perform a test it has to be
403 performed as specified so that the correct semantics are preserved
404 between publisher and receiver.
406 To make the test, the mail receiver MUST evaluate the check_host()
407 function with the arguments described in Section 4.1.
409 Although invalid, malformed, or non-existent domains cause SPF checks
410 to return "none" because no SPF record can be found, it has long been
411 the policy of many MTAs to reject email from such domains, especially
412 in the case of invalid "MAIL FROM". Rejecting email will prevent one
413 method of circumventing of SPF records.
415 Implementations have to take care to correctly extract the <domain>
416 from the data given with the SMTP MAIL FROM command as many MTAs will
417 still accept such things as source routes (see Appendix C of
418 [RFC5321]), the %-hack (see [RFC1123]), and bang paths (see
419 [RFC1983]). These archaic features have been maliciously used to
420 bypass security systems.
4222.3. The "HELO" Identity
425 identity but also separately check the "HELO" identity by applying
426 the check_host() function (Section 4) to the "HELO" identity as the
427 <sender>. Checking "HELO" promotes consistency of results and can
428 reduce DNS resource usage. If a conclusive determination about the
429 message can be made based on a check of "HELO", then the use of DNS
430 resources to process the typically more complex "MAIL FROM" can be
431 avoided. Additionally, since SPF records published for "HELO"
432 identities refer to a single host, when available, they are a very
433 reliable source of host authorization status. Checking "HELO" before
434 "MAIL FROM" is the RECOMMENDED sequence if both are checked.
436 Note that requirements for the domain presented in the EHLO or HELO
437 command are not always clear to the sending party, and SPF verifiers
438 have to be prepared for the identity to be an IP address literal (see
439 [RFC5321], Section 4.1.3) or simply be malformed. This SPF check can
440 only be performed when the "HELO" string is a valid, multi-label
450Kitterman Standards Track [Page 8]
452RFC 7208 Sender Policy Framework (SPF) April 2014
4552.4. The "MAIL FROM" Identity
457 SPF verifiers MUST check the "MAIL FROM" identity if a "HELO" check
458 either has not been performed or has not reached a definitive policy
459 result by applying the check_host() function to the "MAIL FROM"
460 identity as the <sender>.
462 [RFC5321] allows the reverse-path to be null (see Section 4.5.5 in
463 [RFC5321]). In this case, there is no explicit sender mailbox, and
464 such a message can be assumed to be a notification message from the
465 mail system itself. When the reverse-path is null, this document
466 defines the "MAIL FROM" identity to be the mailbox composed of the
467 local-part "postmaster" and the "HELO" identity (which might or might
468 not have been checked separately before).
4702.5. Location of Checks
473 the SMTP transaction that receives the mail. This reduces the
474 complexity of determining the correct IP address to use as an input
475 to check_host() and allows errors to be returned directly to the
476 sending MTA by way of SMTP replies. Appendix D of [RFC7001] provides
477 a more thorough discussion of this topic.
479 The authorization check is performed during the SMTP transaction at
480 the time of the MAIL command, and uses the MAIL FROM value and the
481 client IP address. Performing the check at later times or with other
482 input can cause problems such as the following:
484 o It might be difficult to accurately extract the required
485 information from potentially deceptive headers.
487 o Legitimate email might fail the authorization check because the
488 sender's policy has since changed.
491 failed the authorization check often constitutes backscatter, i.e.,
492 nuisance rejection notices that are not actionable. Operators are
493 strongly advised to avoid such practices. Section 2 of [RFC3834]
494 describes backscatter and the problems it causes.
4962.6. Results of Evaluation
498 Section 4 defines check_host(), a model function definition that uses
499 the inputs defined above and the sender's policy published in the DNS
500 to reach a conclusion about client authorization. An SPF verifier
501 implements something semantically equivalent to the function defined
506Kitterman Standards Track [Page 9]
508RFC 7208 Sender Policy Framework (SPF) April 2014
511 This section enumerates and briefly defines the possible outputs of
512 that function. Note, however, that the protocol establishes no
513 normative requirements for handling any particular result.
514 Discussion of handling options for each result can be found in
519 A result of "none" means either (a) no syntactically valid DNS domain
520 name was extracted from the SMTP session that could be used as the
521 one to be authorized, or (b) no SPF records were retrieved from
526 A "neutral" result means the ADMD has explicitly stated that it is
527 not asserting whether the IP address is authorized.
531 A "pass" result is an explicit statement that the client is
532 authorized to inject mail with the given identity.
536 A "fail" result is an explicit statement that the client is not
537 authorized to use the domain in the given identity.
541 A "softfail" result is a weak statement by the publishing ADMD that
542 the host is probably not authorized. It has not published a
543 stronger, more definitive policy that results in a "fail".
547 A "temperror" result means the SPF verifier encountered a transient
548 (generally DNS) error while performing the check. A later retry may
549 succeed without further DNS operator action.
553 A "permerror" result means the domain's published records could not
554 be correctly interpreted. This signals an error condition that
555 definitely requires DNS operator intervention to be resolved.
562Kitterman Standards Track [Page 10]
564RFC 7208 Sender Policy Framework (SPF) April 2014
569 An SPF record is a DNS record that declares which hosts are, and are
570 not, authorized to use a domain name for the "HELO" and "MAIL FROM"
571 identities. Loosely, the record partitions hosts into permitted and
572 not-permitted sets (though some hosts might fall into neither
575 The SPF record is expressed as a single string of text found in the
577 not permitted for the same owner name. The record format and the
578 process for selecting records are described below in Section 4. An
579 example record is the following:
581 v=spf1 +mx a:colo.example.com/28 -all
583 This record has a version of "spf1" and three directives: "+mx",
584 "a:colo.example.com/28" (the "+" is implied), and "-all".
587 pertains to, not in a subdomain under the owner name. This is
588 similar to how SRV records [RFC2782] are done.
590 The example in this section might be published via these lines in a
593 example.com. TXT "v=spf1 +mx a:colo.example.com/28 -all"
596 published there for other purposes. They might cause problems with
597 size limits (see Section 3.4), and care has to be taken to ensure
598 that only SPF records are used for SPF processing.
600 ADMDs publishing SPF records ought to keep the amount of DNS
601 information needed to evaluate a record to a minimum. Sections 4.6.4
602 and 10.1.1 provide some suggestions about "include" mechanisms and
603 chained "redirect" modifiers.
6053.1. DNS Resource Records
607 SPF records MUST be published as a DNS TXT (type 16) Resource Record
608 (RR) [RFC1035] only. The character content of the record is encoded
609 as [US-ASCII]. Use of alternative DNS RR types was supported in
610 SPF's experimental phase but has been discontinued.
612 In 2003, when SPF was first being developed, the requirements for
613 assignment of a new DNS RR type were considerably more stringent than
614 they are now. Additionally, support for easy deployment of new DNS
618Kitterman Standards Track [Page 11]
620RFC 7208 Sender Policy Framework (SPF) April 2014
623 RR types was not widely deployed in DNS servers and provisioning
624 systems. As a result, developers of SPF found it easier and more
625 practical to use the TXT RR type for SPF records.
627 In its review of [RFC4408], the SPFbis working group concluded that
628 its dual RR type transition model was fundamentally flawed since it
629 contained no common RR type that implementers were required to serve
630 and required to check. Many alternatives were considered to resolve
631 this issue, but ultimately the working group concluded that
632 significant migration to the SPF RR type in the foreseeable future
633 was very unlikely and that the best solution for resolving this
634 interoperability issue was to drop support for the SPF RR type from
635 SPF version 1. See Appendix A of [RFC6686] for further information.
637 The circumstances surrounding SPF's initial deployment a decade ago
638 are unique. If a future update to SPF were developed that did not
639 reuse existing SPF records, it could use the SPF RR type. SPF's use
640 of the TXT RR type for structured data should in no way be taken as
641 precedent for future protocol designers. Further discussion of
642 design considerations when using new DNS RR types can be found in
6453.2. Multiple DNS Records
647 A domain name MUST NOT have multiple records that would cause an
648 authorization check to select more than one record. See Section 4.5
649 for the selection rules.
6513.3. Multiple Strings in a Single DNS Record
653 As defined in [RFC1035], Sections 3.3 and 3.3.14, a single text DNS
654 record can be composed of more than one string. If a published
655 record contains multiple character-strings, then the record MUST be
656 treated as if those strings are concatenated together without adding
659 IN TXT "v=spf1 .... first" "second string..."
663 IN TXT "v=spf1 .... firstsecond string..."
665 TXT records containing multiple strings are useful in constructing
666 records that would exceed the 255-octet maximum length of a
667 character-string within a single TXT record.
674Kitterman Standards Track [Page 12]
676RFC 7208 Sender Policy Framework (SPF) April 2014
681 The published SPF record for a given domain name SHOULD remain small
682 enough that the results of a query for it will fit within 512 octets.
683 Otherwise, there is a possibility of exceeding a DNS protocol limit.
684 This UDP limit is defined in [RFC1035], Section 2.3.4, although it
685 was raised by [RFC2671]. Staying below 512 octets ought to prevent
686 older DNS implementations from failing over to TCP and will work with
687 UDP in the absence of EDNS0 [RFC6891] support. Since the answer size
688 is dependent on many things outside the scope of this document, it is
689 only possible to give this guideline: If the size of the DNS message,
690 the combined length of the DNS name and the text of all the records
691 of a given type is under 450 octets, then DNS answers ought to fit in
692 UDP packets. Records that are too long to fit in a single UDP packet
693 could be silently ignored by SPF verifiers due to firewall and other
694 issues that interfere with the operation of DNS over TCP or using
697 Note that when computing the sizes for replies to queries of the TXT
698 format, one has to take into account any other TXT records published
699 at the domain name. Similarly, the sizes for replies to all queries
700 related to SPF have to be evaluated to fit in a single 512-octet UDP
701 packet (i.e., DNS message size limited to 450 octets).
705 Use of wildcard records for publishing is discouraged, and care has
706 to be taken if they are used. If a zone includes wildcard MX
707 records, it might want to publish wildcard declarations, subject to
708 the same requirements and problems. In particular, the declaration
709 MUST be repeated for any host that has any RR records at all, and for
710 subdomains thereof. Consider the example in [RFC1034],
711 Section 4.3.3. Based on that, we can do the following:
713 EXAMPLE.COM. MX 10 A.EXAMPLE.COM
714 EXAMPLE.COM. TXT "v=spf1 a:A.EXAMPLE.COM -all"
716 *.EXAMPLE.COM. MX 10 A.EXAMPLE.COM
717 *.EXAMPLE.COM. TXT "v=spf1 a:A.EXAMPLE.COM -all"
719 A.EXAMPLE.COM. A 203.0.113.1
720 A.EXAMPLE.COM. MX 10 A.EXAMPLE.COM
721 A.EXAMPLE.COM. TXT "v=spf1 a:A.EXAMPLE.COM -all"
723 *.A.EXAMPLE.COM. MX 10 A.EXAMPLE.COM
724 *.A.EXAMPLE.COM. TXT "v=spf1 a:A.EXAMPLE.COM -all"
730Kitterman Standards Track [Page 13]
732RFC 7208 Sender Policy Framework (SPF) April 2014
735 SPF records have to be listed twice for every name within the zone:
736 once for the name, and once with a wildcard to cover the tree under
737 the name, in order to cover all domains in use in outgoing mail.
7394. The check_host() Function
741 This description is not an application programming interface
742 definition, but rather a function description used to illustrate the
743 algorithm. A compliant SPF implementation MUST produce results
744 semantically equivalent to this description.
746 The check_host() function fetches SPF records, parses them, and
747 evaluates them to determine whether a particular host is or is not
748 permitted to send mail with a given identity. Receiving ADMDs that
749 perform this check MUST correctly evaluate the check_host() function
752 Implementations MAY use a different algorithm than the canonical
753 algorithm defined here, so long as the results are the same in all
758 The check_host() function takes these arguments:
760 <ip> - the IP address of the SMTP client that is emitting
761 the mail, either IPv4 or IPv6.
763 <domain> - the domain that provides the sought-after authorization
764 information; initially, the domain portion of the
765 "MAIL FROM" or "HELO" identity.
767 <sender> - the "MAIL FROM" or "HELO" identity.
769 For recursive evaluations, the domain portion of <sender> might not
770 be the same as the <domain> argument when check_host() is initially
771 evaluated. In most other cases it will be the same (see Section 5.2
772 below). The overall DNS lookup limit for SPF terms described below
773 in Section 4.6.4 must be tracked as a single global limit for all
774 evaluations, not just for a single instance of a recursive
777 Note that the <domain> argument might not be a well-formed domain
779 domain is used, with its associated problems (see Section 2.3). In
780 these cases, check_host() is defined in Section 4.3 to return a
786Kitterman Standards Track [Page 14]
788RFC 7208 Sender Policy Framework (SPF) April 2014
793 The check_host() function can return one of several results described
794 in Section 2.6. Based on the result, the action to be taken is
795 determined by the local policies of the receiver. This is discussed
7984.3. Initial Processing
801 zero-length label not at the end, etc.) or is not a multi-label
802 domain name, or if the DNS lookup returns "Name Error" (RCODE 3, also
803 known as "NXDOMAIN" [RFC2308]), check_host() immediately returns the
804 result "none". DNS RCODEs are defined in [RFC1035]. Properly formed
805 domains are fully qualified domains as defined in [RFC1983]. That
806 is, in the DNS they are implicitly qualified relative to the root
807 (see Section 3.1 of [RFC1034]). Internationalized domain names MUST
808 be encoded as A-labels, as described in Section 2.3 of [RFC5890].
815 In accordance with how the records are published (see Section 3
816 above), a DNS query needs to be made for the <domain> name, querying
819 If the DNS lookup returns a server failure (RCODE 2) or some other
820 error (RCODE other than 0 or 3), or if the lookup times out, then
821 check_host() terminates immediately with the result "temperror".
8234.5. Selecting Records
827 record = version terms *SP
830 Starting with the set of records that were returned by the lookup,
831 discard records that do not begin with a version section of exactly
832 "v=spf1". Note that the version section is terminated by either an
833 SP character or the end of the record. As an example, a record with
834 a version section of "v=spf10" does not match and is discarded.
836 If the resultant record set includes no records, check_host()
838 more than one record, check_host() produces the "permerror" result.
842Kitterman Standards Track [Page 15]
844RFC 7208 Sender Policy Framework (SPF) April 2014
8474.6. Record Evaluation
849 The check_host() function parses and interprets the SPF record to
850 find a result for the current test. The syntax of the record is
851 validated first, and if there are any syntax errors anywhere in the
853 without further interpretation or evaluation.
8554.6.1. Term Evaluation
857 There are two types of terms: mechanisms (defined in Section 5) and
858 modifiers (defined in Section 6). A record contains an ordered list
859 of these as specified in the following Augmented Backus-Naur Form
862 terms = *( 1*SP ( directive / modifier ) )
864 directive = [ qualifier ] mechanism
865 qualifier = "+" / "-" / "?" / "~"
866 mechanism = ( all / include
867 / a / mx / ptr / ip4 / ip6 / exists )
868 modifier = redirect / explanation / unknown-modifier
869 unknown-modifier = name "=" macro-string
870 ; where name is not any known modifier
872 name = ALPHA *( ALPHA / DIGIT / "-" / "_" / "." )
874 Most mechanisms allow a ":" or "/" character after the name.
876 Modifiers always contain an equals ('=') character immediately after
877 the name, and before any ":" or "/" characters that might be part of
880 Terms that do not contain any of "=", ":", or "/" are mechanisms, as
881 defined in Section 5.
883 As per the definition of the ABNF notation in [RFC5234], mechanism
884 and modifier names are case-insensitive.
888 Each mechanism is considered in turn from left to right. If there
889 are no more mechanisms, the result is the default result as described
892 When a mechanism is evaluated, one of three things can happen: it can
893 match, not match, or return an exception.
898Kitterman Standards Track [Page 16]
900RFC 7208 Sender Policy Framework (SPF) April 2014
903 If it matches, processing ends and the qualifier value is returned as
904 the result of that record. If it does not match, processing
905 continues with the next mechanism. If it returns an exception,
906 mechanism processing ends and the exception value is returned.
908 The possible qualifiers, and the results they cause check_host() to
909 return, are as follows:
916 The qualifier is optional and defaults to "+".
918 When a mechanism matches and the qualifier is "-", then a "fail"
919 result is returned and the explanation string is computed as
920 described in Section 6.2.
922 The specific mechanisms are described in Section 5.
926 Modifiers are not mechanisms. They do not return match or not-match.
927 Instead, they provide additional information. Although modifiers do
928 not directly affect the evaluation of the record, the "redirect"
929 modifier has an effect after all the mechanisms have been evaluated.
9314.6.4. DNS Lookup Limits
933 Some mechanisms and modifiers (collectively, "terms") cause DNS
934 queries at the time of evaluation, and some do not. The following
935 terms cause DNS queries: the "include", "a", "mx", "ptr", and
936 "exists" mechanisms, and the "redirect" modifier. SPF
938 during SPF evaluation, to avoid unreasonable load on the DNS. If
939 this limit is exceeded, the implementation MUST return "permerror".
940 The other terms -- the "all", "ip4", and "ip6" mechanisms, and the
941 "exp" modifier -- do not cause DNS queries at the time of SPF
942 evaluation (the "exp" modifier only causes a lookup at a later time),
943 and their use is not subject to this limit.
946 records queried is included in the overall limit of 10 mechanisms/
948 that limit, the evaluation of each "MX" record MUST NOT result in
954Kitterman Standards Track [Page 17]
956RFC 7208 Sender Policy Framework (SPF) April 2014
959 querying more than 10 address records -- either "A" or "AAAA"
960 resource records. If this limit is exceeded, the "mx" mechanism MUST
961 produce a "permerror" result.
964 "PTR" resource records queried is included in the overall limit of 10
965 mechanisms/modifiers that cause DNS lookups as described above. In
966 addition to that limit, the evaluation of each "PTR" record MUST NOT
967 result in querying more than 10 address records -- either "A" or
968 "AAAA" resource records. If this limit is exceeded, all records
969 other than the first 10 MUST be ignored.
971 The reason for the disparity is that the set of and contents of the
972 MX record are under control of the publishing ADMD, while the set of
973 and contents of PTR records are under control of the owner of the IP
974 address actually making the connection.
976 These limits are per mechanism or macro in the record, and are in
977 addition to the lookup limits specified above.
979 MTAs or other processors SHOULD impose a limit on the maximum amount
980 of elapsed time to evaluate check_host(). Such a limit SHOULD allow
981 at least 20 seconds. If such a limit is exceeded, the result of
982 authorization SHOULD be "temperror".
985 is useful to limit the number of "terms" for which DNS queries return
986 either a positive answer (RCODE 0) with an answer count of 0, or a
987 "Name Error" (RCODE 3) answer. These are sometimes collectively
989 "void lookups" to two. An implementation MAY choose to make such a
990 limit configurable. In this case, a default of two is RECOMMENDED.
991 Exceeding the limit produces a "permerror" result.
995 If none of the mechanisms match and there is no "redirect" modifier,
997 "?all" were specified as the last directive. If there is a
998 "redirect" modifier, check_host() proceeds as defined in Section 6.1.
1000 It is better to use either a "redirect" modifier or an "all"
1001 mechanism to explicitly terminate processing. Although there is an
1002 implicit "?all" at the end of every record that is not explicitly
1003 terminated, it aids debugging efforts when it is explicitly provided.
1010Kitterman Standards Track [Page 18]
1012RFC 7208 Sender Policy Framework (SPF) April 2014
1021 v=spf1 +mx redirect=_spf.example.com
10234.8. Domain Specification
1025 Several of these mechanisms and modifiers have a <domain-spec>
1026 section. The <domain-spec> string is subject to macro expansion (see
1027 Section 7). The resulting string is the common presentation form of
1028 a fully qualified DNS name: a series of labels separated by periods.
1029 This domain is called the <target-name> in the rest of this document.
1031 Note: The result of the macro expansion is not subject to any further
1032 escaping. Hence, this facility cannot produce all characters that
1033 are legal in a DNS label (e.g., the control characters). However,
1034 this facility is powerful enough to express legal host names and
1035 common utility labels (such as "_spf") that are used in DNS.
1038 provided, the <domain> from the check_host() arguments (see
1039 Section 4.1) is used as the <target-name>. "domain" and
1040 <domain-spec> are syntactically identical after macro expansion.
1041 "domain" is an input value for check_host(), while <domain-spec> is
1042 computed by check_host().
1044 The result of evaluating check_host() with a syntactically invalid
1045 domain is undefined.
1048 defining correct handling of a syntactically invalid <domain-spec>
1049 (which might be the result of macro expansion), per [RFC1035].
1050 Examples include names with empty labels, such as "foo..example.com",
1051 and labels that are longer than 63 characters. Some implementations
1052 choose to treat such errors as not-match and therefore ignore such
1053 names, while others return a "permerror" exception.
1066Kitterman Standards Track [Page 19]
1068RFC 7208 Sender Policy Framework (SPF) April 2014
10715. Mechanism Definitions
1073 This section defines two types of mechanisms: basic language
1074 framework mechanisms and designated sender mechanisms.
1076 Basic mechanisms contribute to the language framework. They do not
1077 specify a particular type of authorization scheme. The basic
1078 mechanisms are as follows:
1083 Designated sender mechanisms are used to identify a set of <ip>
1084 addresses as being permitted or not permitted to use the <domain> for
1085 sending mail. The designated sender mechanisms are as follows:
1094 The following conventions apply to all mechanisms that perform a
1095 comparison between <ip> and an IP address at any point:
1098 IP address are compared for equality. (Here, CIDR is Classless
1099 Inter-Domain Routing, described in [RFC4632].)
1101 If a CIDR prefix length is specified, then only the specified number
1102 of high-order bits of <ip> and the IP address are compared for
1105 When any mechanism fetches host addresses to compare with <ip>, when
1106 <ip> is an IPv4, "A" records are fetched; when <ip> is an IPv6
1107 address, "AAAA" records are fetched. SPF implementations on IPv6
1108 servers need to handle both "AAAA" and "A" records, for clients on
1109 IPv4-mapped IPv6 addresses [RFC4291]. IPv4 <ip> addresses are only
1110 listed in an SPF record using the "ip4" mechanism.
1112 Several mechanisms rely on information fetched from the DNS. For
1113 these DNS queries, except where noted, if the DNS server returns an
1114 error (RCODE other than 0 or 3) or the query times out, the mechanism
1115 stops and the topmost check_host() returns "temperror". If the
1117 mechanism continues as if the server returned no error (RCODE 0) and
1118 zero answer records.
1122Kitterman Standards Track [Page 20]
1124RFC 7208 Sender Policy Framework (SPF) April 2014
1131 The "all" mechanism is a test that always matches. It is used as the
1132 rightmost mechanism in a record to provide an explicit default.
1138 Mechanisms after "all" will never be tested. Mechanisms listed after
1139 "all" MUST be ignored. Any "redirect" modifier (Section 6.1) MUST be
1140 ignored when there is an "all" mechanism in the record, regardless of
1141 the relative ordering of the terms.
1145 include = "include" ":" domain-spec
1147 The "include" mechanism triggers a recursive evaluation of
1150 1. The <domain-spec> is expanded as per Section 7.
1152 2. check_host() is evaluated with the resulting string as the
1153 <domain>. The <ip> and <sender> arguments remain the same as in
1154 the current evaluation of check_host().
1156 3. The recursive evaluation returns match, not-match, or an error.
1158 4. If it returns match, then the appropriate result for the
1159 "include" mechanism is used (e.g., include or +include produces a
1160 "pass" result and -include produces "fail").
1162 5. If it returns not-match or an error, the parent check_host()
1163 resumes processing as per the table below, with the previous
1164 value of <domain> restored.
1166 In hindsight, the name "include" was poorly chosen. Only the
1167 evaluated result of the referenced SPF record is used, rather than
1168 literally including the mechanisms of the referenced record in the
1169 first. For example, evaluating a "-all" directive in the referenced
1170 record does not terminate the overall processing and does not
1171 necessarily result in an overall "fail". (Better names for this
1172 mechanism would have been "if-match", "on-match", etc.)
1178Kitterman Standards Track [Page 21]
1180RFC 7208 Sender Policy Framework (SPF) April 2014
1183 The "include" mechanism makes it possible for one domain to designate
1184 multiple administratively independent domains. For example, a vanity
1185 domain "example.net" might send mail using the servers of
1186 administratively independent domains example.com and example.org.
1188 Example.net could say
1190 IN TXT "v=spf1 include:example.com include:example.org -all"
1192 This would direct check_host() to, in effect, check the records of
1193 example.com and example.org for a "pass" result. Only if the host
1194 were not permitted for either of those domains would the result be
1197 Whether this mechanism matches, does not match, or returns an
1198 exception depends on the result of the recursive evaluation of
1201 +---------------------------------+---------------------------------+
1204 +---------------------------------+---------------------------------+
1207 | fail | not match |
1209 | softfail | not match |
1211 | neutral | not match |
1213 | temperror | return temperror |
1215 | permerror | return permerror |
1217 | none | return permerror |
1218 +---------------------------------+---------------------------------+
1220 The "include" mechanism is intended for crossing administrative
1221 boundaries. When remaining within one administrative authority,
1222 "include" is usually not the best choice. For example, if
1223 example.com and example.org were managed by the same entity, and if
1224 the permitted set of hosts for both domains was "mx:example.com", it
1225 would be possible for example.org to specify "include:example.com",
1226 but it would be preferable to specify "redirect=example.com" or even
1234Kitterman Standards Track [Page 22]
1236RFC 7208 Sender Policy Framework (SPF) April 2014
1239 With the "include" mechanism, an administratively external set of
1240 hosts can be authorized, but determination of sender policy is still
1241 a function of the original domain's SPF record (as determined by the
1242 "all" mechanism in that record). The "redirect" modifier is more
1243 suitable for consolidating both authorizations and policy into a
1244 common set to be shared within an ADMD. Redirect is much more like a
1245 common code element to be shared among records in a single ADMD. It
1246 is possible to control both authorized hosts and policy for an
1247 arbitrary number of domains from a single record.
1251 This mechanism matches if <ip> is one of the <target-name>'s IP
1252 addresses. For clarity, this means the "a" mechanism also matches
1255 a = "a" [ ":" domain-spec ] [ dual-cidr-length ]
1257 An address lookup is done on the <target-name> using the type of
1258 lookup (A or AAAA) appropriate for the connection type (IPv4 or
1259 IPv6). The <ip> is compared to the returned address(es). If any
1260 address matches, the mechanism matches.
1264 This mechanism matches if <ip> is one of the MX hosts for a domain
1267 mx = "mx" [ ":" domain-spec ] [ dual-cidr-length ]
1269 check_host() first performs an MX lookup on the <target-name>. Then
1270 it performs an address lookup on each MX name returned. The <ip> is
1271 compared to each returned IP address. To prevent denial-of-service
1272 (DoS) attacks, the processing limits defined in Section 4.6.4 MUST be
1273 followed. If the MX lookup limit is exceeded, then "permerror" is
1274 returned and the evaluation is terminated. If any address matches,
1275 the mechanism matches.
1277 Note regarding implicit MXes: If the <target-name> has no MX record,
1278 check_host() MUST NOT apply the implicit MX rules of [RFC5321] by
1279 querying for an A or AAAA record for the same name.
1283 This mechanism tests whether the DNS reverse-mapping for <ip> exists
1284 and correctly points to a domain name within a particular domain.
1285 This mechanism SHOULD NOT be published. See the note at the end of
1286 this section for more information.
1290Kitterman Standards Track [Page 23]
1292RFC 7208 Sender Policy Framework (SPF) April 2014
1295 ptr = "ptr" [ ":" domain-spec ]
1299 o Perform a DNS reverse-mapping for <ip>: Look up the corresponding
1300 PTR record in "in-addr.arpa." if the address is an IPv4 address
1301 and in "ip6.arpa." if it is an IPv6 address.
1303 o For each record returned, validate the domain name by looking up
1304 its IP addresses. To prevent DoS attacks, the PTR processing
1305 limits defined in Section 4.6.4 MUST be applied. If they are
1306 exceeded, processing is terminated and the mechanism does not
1309 o If <ip> is among the returned IP addresses, then that domain name
1312 Check all validated domain names to see if they either match the
1313 <target-name> domain or are a subdomain of the <target-name> domain.
1314 If any do, this mechanism matches. If no validated domain name can
1315 be found, or if none of the validated domain names match or are a
1316 subdomain of the <target-name>, this mechanism fails to match. If a
1317 DNS error occurs while doing the PTR RR lookup, then this mechanism
1318 fails to match. If a DNS error occurs while doing an A RR lookup,
1319 then that domain name is skipped and the search continues.
1321 This mechanism matches if
1325 o the <target-name> and a validated domain name are the same.
1327 For example, "mail.example.com" is within the domain "example.com",
1328 but "mail.bad-example.com" is not.
1330 Note: This mechanism is slow, it is not as reliable as other
1331 mechanisms in cases of DNS errors, and it places a large burden on
1332 the .arpa name servers. If used, proper PTR records have to be in
1333 place for the domain's hosts and the "ptr" mechanism SHOULD be one of
1334 the last mechanisms checked. After many years of SPF deployment
1335 experience, it has been concluded that it is unnecessary and more
1336 reliable alternatives should be used instead. It is, however, still
1337 in use as part of the SPF protocol, so compliant check_host()
1338 implementations MUST support it.
1346Kitterman Standards Track [Page 24]
1348RFC 7208 Sender Policy Framework (SPF) April 2014
1353 These mechanisms test whether <ip> is contained within a given
1356 ip4 = "ip4" ":" ip4-network [ ip4-cidr-length ]
1357 ip6 = "ip6" ":" ip6-network [ ip6-cidr-length ]
1359 ip4-cidr-length = "/" ("0" / %x31-39 0*1DIGIT) ; value range 0-32
1360 ip6-cidr-length = "/" ("0" / %x31-39 0*2DIGIT) ; value range 0-128
1361 dual-cidr-length = [ ip4-cidr-length ] [ "/" ip6-cidr-length ]
1363 ip4-network = qnum "." qnum "." qnum "." qnum
1365 / %x31-39 DIGIT ; 10-99
1366 / "1" 2DIGIT ; 100-199
1367 / "2" %x30-34 DIGIT ; 200-249
1368 / "25" %x30-35 ; 250-255
1369 ; as per conventional dotted-quad notation, e.g., 192.0.2.0
1371 ip6-network = <as per Section 2.2 of [RFC4291]>
1372 ; e.g., 2001:db8::cd30
1374 The <ip> is compared to the given network. If CIDR prefix length
1375 high-order bits match, the mechanism matches.
1377 If ip4-cidr-length is omitted, it is taken to be "/32". If
1378 ip6-cidr-length is omitted, it is taken to be "/128". It is not
1379 permitted to omit parts of the IP address instead of using CIDR
1380 notations. That is, use 192.0.2.0/24 instead of 192.0.2.
1384 This mechanism is used to construct an arbitrary domain name that is
1385 used for a DNS A record query. It allows for complicated schemes
1386 involving arbitrary parts of the mail envelope to determine what is
1389 exists = "exists" ":" domain-spec
1391 The <domain-spec> is expanded as per Section 7. The resulting domain
1392 name is used for a DNS A RR lookup (even when the connection type is
1393 IPv6). If any A record is returned, this mechanism matches.
1395 Domains can use this mechanism to specify arbitrarily complex
1396 queries. For example, suppose example.com publishes the record:
1398 v=spf1 exists:%{ir}.%{l1r+-}._spf.%{d} -all
1402Kitterman Standards Track [Page 25]
1404RFC 7208 Sender Policy Framework (SPF) April 2014
1407 The <target-name> might expand to
1408 "1.2.0.192.someuser._spf.example.com". This makes fine-grained
1409 decisions possible at the level of the user and client IP address.
14116. Modifier Definitions
1413 Modifiers are name/value pairs that provide additional information.
1414 Modifiers always have an "=" separating the name and the value.
1416 The modifiers defined in this document ("redirect" and "exp") SHOULD
1417 appear at the end of the record, after all mechanisms, though
1418 syntactically they can appear anywhere in the record. Ordering of
1420 appear in a record more than once each. If they do, then
1421 check_host() exits with a result of "permerror".
1424 they appear in a record. This allows implementations conforming to
1425 this document to gracefully handle records with modifiers that are
1426 defined in other specifications.
14286.1. redirect: Redirected Query
1430 The "redirect" modifier is intended for consolidating both
1431 authorizations and policy into a common set to be shared within a
1432 single ADMD. It is possible to control both authorized hosts and
1433 policy for an arbitrary number of domains from a single record.
1435 redirect = "redirect" "=" domain-spec
1437 If all mechanisms fail to match, and a "redirect" modifier is
1438 present, then processing proceeds as follows:
1441 the macro rules in Section 7. Then check_host() is evaluated with
1442 the resulting string as the <domain>. The <ip> and <sender>
1443 arguments remain the same as in the current evaluation of
1446 The result of this new evaluation of check_host() is then considered
1447 the result of the current evaluation with the exception that if no
1448 SPF record is found, or if the <target-name> is malformed, the result
1449 is a "permerror" rather than "none".
1451 Note that the newly queried domain can itself specify redirect
1458Kitterman Standards Track [Page 26]
1460RFC 7208 Sender Policy Framework (SPF) April 2014
1463 This facility is intended for use by organizations that wish to apply
1464 the same record to multiple domains. For example:
1466 la.example.com. TXT "v=spf1 redirect=_spf.example.com"
1467 ny.example.com. TXT "v=spf1 redirect=_spf.example.com"
1468 sf.example.com. TXT "v=spf1 redirect=_spf.example.com"
1469 _spf.example.com. TXT "v=spf1 mx:example.com -all"
1471 In this example, mail from any of the three domains is described by
1472 the same record. This can be an administrative advantage.
1474 Note: In general, the domain "A" cannot reliably use a redirect to
1475 another domain "B" not under the same administrative control. Since
1476 the <sender> stays the same, there is no guarantee that the record at
1477 domain "B" will correctly work for mailboxes in domain "A",
1478 especially if domain "B" uses mechanisms involving local-parts. An
1479 "include" directive will generally be more appropriate.
1481 For clarity, any "redirect" modifier SHOULD appear as the very last
1482 term in a record. Any "redirect" modifier MUST be ignored if there
1483 is an "all" mechanism anywhere in the record.
1487 explanation = "exp" "=" domain-spec
1490 "-all"), and the "exp" modifier is present, then the explanation
1492 is present, then either a default explanation string or an empty
1493 explanation string MUST be returned to the calling application.
1495 The <domain-spec> is macro expanded (see Section 7) and becomes the
1496 <target-name>. The DNS TXT RRset for the <target-name> is fetched.
1498 If there are any DNS processing errors (any RCODE other than 0), or
1499 if no records are returned, or if more than one record is returned,
1500 or if there are syntax errors in the explanation string, then proceed
1501 as if no "exp" modifier was given.
1503 The fetched TXT record's strings are concatenated with no spaces, and
1504 then treated as an explain-string, which is macro-expanded. This
1505 final result is the explanation string. Implementations MAY limit
1506 the length of the resulting explanation string to allow for other
1508 explanation string is intended for an SMTP response and Section 2.4
1509 of [RFC5321] says that responses are in [US-ASCII], the explanation
1510 string MUST be limited to [US-ASCII].
1514Kitterman Standards Track [Page 27]
1516RFC 7208 Sender Policy Framework (SPF) April 2014
1519 Software evaluating check_host() can use this string to communicate
1520 information from the publishing domain in the form of a short message
1521 or URL. Software SHOULD make it clear that the explanation string
1522 comes from a third party. For example, it can prepend the macro
1523 string "%{o} explains: " to the explanation, as shown in the example
1526 Suppose example.com has this record:
1528 v=spf1 mx -all exp=explain._spf.%{d}
1530 Here are some examples of possible explanation TXT records at
1531 explain._spf.example.com:
1533 "Mail from example.com should only be sent by its own servers."
1535 -- a simple, constant message
1537 "%{i} is not one of %{d}'s designated mail servers."
1539 -- a message with a little more information, including the
1540 IP address that failed the check
1542 "See http://%{d}/why.html?s=%{S}&i=%{I}"
1544 -- a complicated example that constructs a URL with the
1545 arguments to check_host() so that a web page can be
1546 generated with detailed, custom instructions
1549 from the <target-name> MUST NOT be used. In contrast, when executing
1550 a "redirect" modifier, an "exp" modifier from the original domain
1551 MUST NOT be used. This is because "include" is meant to cross
1552 administrative boundaries and the explanation provided should be the
1553 one from the receiving ADMD, while "redirect" is meant to operate as
1554 a tool to consolidate policy records within an ADMD so the redirected
1555 explanation is the one that ought to have priority.
1559 When evaluating an SPF policy record, certain character sequences are
1560 intended to be replaced by parameters of the message or of the
1561 connection. These character sequences are referred to as "macros".
1570Kitterman Standards Track [Page 28]
1572RFC 7208 Sender Policy Framework (SPF) April 2014
15757.1. Formal Specification
1577 The ABNF description for a macro is as follows:
1580 domain-end = ( "." toplabel [ "." ] ) / macro-expand
1582 toplabel = ( *alphanum ALPHA *alphanum ) /
1583 ( 1*alphanum "-" *( alphanum / "-" ) alphanum )
1584 alphanum = ALPHA / DIGIT
1586 explain-string = *( macro-string / SP )
1589 macro-expand = ( "%{" macro-letter transformers *delimiter "}" )
1590 / "%%" / "%_" / "%-"
1591 macro-literal = %x21-24 / %x26-7E
1592 ; visible characters except "%"
1593 macro-letter = "s" / "l" / "o" / "d" / "i" / "p" / "h" /
1594 "c" / "r" / "t" / "v"
1595 transformers = *DIGIT [ "r" ]
1596 delimiter = "." / "-" / "+" / "," / "/" / "_" / "="
1598 The "toplabel" construction is subject to the letter-digit-hyphen
1599 (LDH) rule plus additional top-level domain (TLD) restrictions. See
1600 Section 2 of [RFC3696] for background.
1604 o A literal "%" is expressed by "%%".
1606 o "%_" expands to a single " " space.
1608 o "%-" expands to a URL-encoded space, viz., "%20".
16107.2. Macro Definitions
1612 The following macro letters are expanded in term arguments:
1615 l = local-part of <sender>
1616 o = domain of <sender>
1619 p = the validated domain name of <ip> (do not use)
1620 v = the string "in-addr" if <ip> is ipv4, or "ip6" if <ip> is ipv6
1626Kitterman Standards Track [Page 29]
1628RFC 7208 Sender Policy Framework (SPF) April 2014
1631 <domain>, <sender>, and <ip> are defined in Section 4.1.
1633 The following macro letters are allowed only in "exp" text:
1635 c = SMTP client IP (easily readable format)
1636 r = domain name of host performing the check
1637 t = current timestamp
1644 -exists:%(ir).sbl.example.org
1646 is incorrect and will cause check_host() to yield a "permerror".
1647 Instead, the following is legal:
1649 -exists:%{ir}.sbl.example.org
1651 Optional transformers are the following:
1653 *DIGIT = zero or more digits
1657 If transformers or delimiters are provided, the replacement value for
1658 a macro letter is split into parts separated by one or more of the
1660 operation and/or removal of left-hand parts, the parts are rejoined
1661 using "." and not the original splitting characters.
1663 By default, strings are split on "." (dots). Note that no special
1664 treatment is given to leading, trailing, or consecutive delimiters in
1665 input strings, and so the list of parts might contain empty strings.
1666 Some older implementations of SPF prohibit trailing dots in domain
1667 names, so trailing dots SHOULD NOT be published, although they MUST
1668 be accepted by implementations conforming to this document. Macros
1669 can specify delimiter characters that are used instead of ".".
1671 The "r" transformer indicates a reversal operation: if the client IP
1672 address were 192.0.2.1, the macro %{i} would expand to "192.0.2.1"
1673 and the macro %{ir} would expand to "1.2.0.192".
1675 The DIGIT transformer indicates the number of right-hand parts to
1676 use, after optional reversal. If a DIGIT is specified, the value
1677 MUST be nonzero. If no DIGITs are specified, or if the value
1678 specifies more parts than are available, all the available parts are
1682Kitterman Standards Track [Page 30]
1684RFC 7208 Sender Policy Framework (SPF) April 2014
1687 used. If the DIGIT was 5, and only 3 parts were available, the macro
1688 interpreter would pretend the DIGIT was 3. Implementations MUST
1689 support at least a value of 127, as that is the maximum number of
1690 labels in a domain name (less the zero-length label at the end).
1692 The "s" macro expands to the <sender> argument. It is an email
1693 address with a local-part, an "@" character, and a domain. The "l"
1694 macro expands to just the local-part. The "o" macro expands to just
1695 the domain part. Note that these values remain the same during
1696 recursive and chained evaluations due to "include" and/or "redirect".
1697 Note also that if the original <sender> had no local-part, the
1698 local-part was set to "postmaster" in initial processing (see
1701 For IPv4 addresses, both the "i" and "c" macros expand to the
1702 standard dotted-quad format.
1704 For IPv6 addresses, the "i" macro expands to a dot-format address; it
1705 is intended for use in %{ir}. The "c" macro can expand to any of the
1706 hexadecimal colon-format addresses specified in Section 2.2 of
1707 [RFC4291]. It is intended for humans to read.
1710 procedure for finding the validated domain name is defined in
1711 Section 5.5. If the <domain> is present in the list of validated
1712 domains, it SHOULD be used. Otherwise, if a subdomain of the
1713 <domain> is present, it SHOULD be used. Otherwise, any name from the
1715 error occurs, the string "unknown" is used.
1717 This macro SHOULD NOT be published (see Section 5.5 for the
1720 The "h" macro expands to the parameter that was provided to the SMTP
1721 server via the HELO or EHLO SMTP verb. For sessions where that verb
1722 was provided more than once, the most recent instance is used.
1724 The "r" macro expands to the name of the receiving MTA. This SHOULD
1725 be a fully qualified domain name, but if one does not exist (as when
1726 the checking is done by a Mail User Agent (MUA)) or if policy
1727 restrictions dictate otherwise, the word "unknown" SHOULD be
1728 substituted. The domain name can be different from the name found in
1729 the MX record that the client MTA used to locate the receiving MTA.
1738Kitterman Standards Track [Page 31]
1740RFC 7208 Sender Policy Framework (SPF) April 2014
1743 The "t" macro expands to the decimal representation of the
1744 approximate number of seconds since the Epoch (Midnight, January 1,
1745 1970, UTC) at the time of the evaluation. This is the same value as
1746 the value that is returned by the Portable Operating System Interface
1747 (POSIX) time() function in most standards-compliant libraries.
1750 the expanded domain name exceeds 253 characters (the maximum length
1751 of a domain name in this format), the left side is truncated to fit,
1752 by removing successive domain labels (and their following dots) until
1753 the total length does not exceed 253 characters.
1756 are then URL escaped. URL escaping MUST be performed for characters
1757 not in the "unreserved" set, which is defined in [RFC3986].
1759 Care has to be taken by the sending ADMD so that macro expansion for
1760 legitimate email does not exceed the 63-character limit on DNS
1761 labels. The local-part of email addresses, in particular, can have
1762 more than 63 characters between dots.
1764 To minimize DNS lookup resource requirements, it is better if sending
1765 ADMDs avoid using the "s", "l", "o", or "h" macros in conjunction
1766 with any mechanism directive. Although these macros are powerful and
1767 allow per-user records to be published, they severely limit the
1768 ability of implementations to cache results of check_host() and they
1769 reduce the effectiveness of DNS caches.
1771 If no directive processed during the evaluation of check_host()
1772 contains an "s", "l", "o", or "h" macro, then the results of the
1773 evaluation can be cached on the basis of <domain> and <ip> alone for
1774 as long as the DNS record involved with the shortest Time to Live
1775 (TTL) has not expired.
1779 The <sender> is strong-bad@email.example.com. The IPv4 SMTP client
1780 IP is 192.0.2.3. The IPv6 SMTP client IP is 2001:db8::cb01. The PTR
1781 domain name of the client IP is mx.example.org.
1794Kitterman Standards Track [Page 32]
1796RFC 7208 Sender Policy Framework (SPF) April 2014
1800 ------- ----------------------------
1801 %{s} strong-bad@email.example.com
1802 %{o} email.example.com
1803 %{d} email.example.com
1804 %{d4} email.example.com
1805 %{d3} email.example.com
1808 %{dr} com.example.email
1809 %{d2r} example.email
1816 macro-string expansion
1817 --------------------------------------------------------------------
1818 %{ir}.%{v}._spf.%{d2} 3.2.0.192.in-addr._spf.example.com
1819 %{lr-}.lp._spf.%{d2} bad.strong.lp._spf.example.com
1821 %{lr-}.lp.%{ir}.%{v}._spf.%{d2}
1822 bad.strong.lp.3.2.0.192.in-addr._spf.example.com
1824 %{ir}.%{v}.%{l1r-}.lp._spf.%{d2}
1825 3.2.0.192.in-addr.strong.lp._spf.example.com
1827 %{d2}.trusted-domains.example.net
1828 example.com.trusted-domains.example.net
1831 %{ir}.%{v}._spf.%{d2} 1.0.b.c.0.0.0.0.
1832 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6._spf.example.com
1837 to the various possible outputs of check_host() on a message.
1838 Definitions of SPF results are presented in Section 2.6; this section
1839 provides more detail on each for use in developing local policy for
1842 Every operating environment is different. There are some receivers
1843 for whom strict adherence to SPF is appropriate, and definitive
1844 treatment of messages that are evaluated to be explicitly
1845 unauthorized ("fail" and sometimes "softfail") is the norm. There
1846 are others for which the "false negative" cases are more of a
1850Kitterman Standards Track [Page 33]
1852RFC 7208 Sender Policy Framework (SPF) April 2014
1855 concern. This concern is typically handled by merely recording the
1856 result in the header and allowing the message to pass on for
1857 additional processing. There are still others where SPF is one of
1858 several inputs to the message-handling decision. As such, there is
1859 no comprehensive normative requirement for message handling in
1860 response to any particular result. This section is provided to
1861 present a complete picture of the likely cause of each result and,
1862 where available, the experience gained during experimental
1865 There are essentially two classes of handling choices:
1867 o Handling within the SMTP session that attempted to deliver the
1868 message, such as by returning a permanent SMTP error (rejection)
1869 or temporary SMTP error ("try again later");
1871 o Permitting the message to pass (a successful SMTP reply code) and
1872 adding an additional header field that indicates the result
1873 returned by check_host() and other salient details; this is
1874 discussed in more detail in Section 9.
1878 With a "none" result, the SPF verifier has no information at all
1879 about the authorization or lack thereof of the client to use the
1880 checked identity or identities. The check_host() function completed
1881 without errors but was not able to reach any conclusion.
1885 A "neutral" result indicates that although a policy for the identity
1886 was discovered, there is no definite assertion (positive or negative)
1889 A "neutral" result MUST be treated exactly like the "none" result;
1890 the distinction exists only for informational purposes. Treating
1891 "neutral" more harshly than "none" would discourage ADMDs from
1892 testing the use of SPF records (see Section 10.1).
1896 A "pass" result means the client is authorized to inject mail with
1897 the given identity. The domain can now, in the sense of reputation,
1898 be considered responsible for sending the message. Further policy
1899 checks can now proceed with confidence in the legitimate use of the
1900 identity. This is further discussed in Appendix G.1.
1906Kitterman Standards Track [Page 34]
1908RFC 7208 Sender Policy Framework (SPF) April 2014
1913 A "fail" result is an explicit statement that the client is not
1914 authorized to use the domain in the given identity. Disposition of
1915 SPF fail messages is a matter of local policy. See Appendix G.2 for
1916 considerations on developing local policy.
1918 If the checking software chooses to reject the mail during the SMTP
1919 transaction, then it SHOULD use an SMTP reply code of 550 (see
1920 [RFC5321]) and, if supported, the 5.7.1 enhanced status code (see
1921 [RFC3463], Section 3.8), in addition to an appropriate reply text.
1922 The check_host() function will return either a default explanation
1923 string or one from the domain that published the SPF records (see
1924 Section 6.2). If the information does not originate with the
1925 checking software, it is good to make it clear that the text is
1926 provided by the sender's domain. For example:
1929 550 5.7.1 The domain example.com explains:
1930 550 5.7.1 Please see http://www.example.com/mailpolicy.html
1932 If the checking software chooses not to reject the mail during the
1933 SMTP transaction, then it SHOULD add a Received-SPF or
1934 Authentication-Results header field (see Section 9) to communicate
1935 this result to downstream message processors. While this is true for
1936 all SPF results, it is of particular importance for "fail" results
1937 since the message is explicitly not authorized by the ADMD.
1941 A "softfail" result ought to be treated as somewhere between "fail"
1942 and "neutral"/"none". The ADMD believes the host is not authorized
1943 but is not willing to make a strong policy statement. Receiving
1944 software SHOULD NOT reject the message based solely on this result,
1945 but MAY subject the message to closer scrutiny than normal.
1947 The ADMD wants to discourage the use of this host and thus desires
1948 limited feedback when a "softfail" result occurs. For example, the
1949 recipient's MUA could highlight the "softfail" status, or the
1950 receiving MTA could give the sender a message using greylisting
1951 [RFC6647], with a note the first time the message is received, but
1952 accept it on a later attempt based on receiver policy.
1962Kitterman Standards Track [Page 35]
1964RFC 7208 Sender Policy Framework (SPF) April 2014
1969 A "temperror" result means the SPF verifier encountered a transient
1970 (generally DNS) error while performing the check. Checking software
1971 can choose to accept or temporarily reject the message. If the
1972 message is rejected during the SMTP transaction for this reason, the
1973 software SHOULD use an SMTP reply code of 451 and, if supported, the
1974 4.4.3 enhanced status code (see Section 3.5 of [RFC3463]). These
1975 errors can be caused by problems in either the sender's or receiver's
1976 DNS software. See Appendix G.4 for considerations on developing
1981 A "permerror" result means the domain's published records could not
1982 be correctly interpreted. This signals an error condition that
1983 definitely requires DNS operator intervention to be resolved. If the
1984 message is rejected during the SMTP transaction for this reason, the
1985 software SHOULD use an SMTP reply code of 550 and, if supported, the
1986 5.5.2 enhanced status code (see [RFC3463], Section 3.6). Be aware
1987 that if the ADMD uses macros (Section 7), it is possible that this
1988 result is due to the checked identities having an unexpected format.
1989 It is also possible that this result is generated by certain SPF
1990 verifiers due to the input arguments having an unexpected format; see
1991 Section 4.8. See Appendix G.3 for considerations on developing local
19949. Recording the Result
1996 To provide downstream agents, such as MUAs, with the information they
1997 might need in terms of evaluating or representing the apparent safety
1998 of the message content, it is RECOMMENDED that SMTP receivers record
1999 the result of SPF processing in the message header. For SPF verifier
2000 operators that choose to record SPF results in the header of the
2001 message for processing by internal filters or MUAs, two methods are
2002 presented: Section 9.1 defines the Received-SPF field, which is the
2003 results field originally defined for SPF use. Section 9.2 discusses
2004 the Authentication-Results header field [RFC7001], which was
2005 specified more recently and is designed for use by SPF and other
2006 authentication methods.
2008 Both are in common use, and hence both are included here. However,
2009 it is important to note that they were designed to serve slightly
2010 different purposes. Received-SPF is intended to include enough
2011 information to enable reconstruction of the SPF evaluation of the
2012 message, while Authentication-Results is designed only to relay the
2013 result itself and related output details of likely use to end users
2014 (e.g., what property of the message was actually authenticated and
2018Kitterman Standards Track [Page 36]
2020RFC 7208 Sender Policy Framework (SPF) April 2014
2023 what it contained), leaving reconstructive work to the purview of
2024 system logs and the Received field contents. Also, Received-SPF
2025 relies on compliance of agents within the receiving ADMD to adhere to
2026 the header field ordering rules of [RFC5321] and [RFC5322], while
2027 Authentication-Results includes some provisions to protect against
2028 non-compliant implementations.
2030 An SPF verifier operator could choose to use both to serve different
2031 downstream agents. In such cases, care needs to be taken to ensure
2032 that both fields are conveying the same details, or unexpected
20359.1. The Received-SPF Header Field
2037 The Received-SPF header field is a trace field (see [RFC5322],
2039 the Received: field that is generated by the SMTP receiver. It MUST
2040 appear above all other Received-SPF fields in the message. The
2041 header field has the following format:
2044 [ key-value-list ] CRLF
2046 result = "pass" / "fail" / "softfail" / "neutral" /
2047 "none" / "temperror" / "permerror"
2049 key-value-list = key-value-pair *( ";" [CFWS] key-value-pair )
2052 key-value-pair = key [CFWS] "=" ( dot-atom / quoted-string )
2054 key = "client-ip" / "envelope-from" / "helo" /
2055 "problem" / "receiver" / "identity" /
2058 identity = "mailfrom" ; for the "MAIL FROM" identity
2059 / "helo" ; for the "HELO" identity
2060 / name ; other identities
2062 dot-atom = <unquoted word as per [RFC5322]>
2063 quoted-string = <quoted string as per [RFC5322]>
2064 comment = <comment string as per [RFC5322]>
2065 CFWS = <comment or folding white space as per [RFC5322]>
2066 FWS = <folding white space as per [RFC5322]>
2067 CRLF = <standard end-of-line token as per [RFC5322]>
2074Kitterman Standards Track [Page 37]
2076RFC 7208 Sender Policy Framework (SPF) April 2014
2079 The header field SHOULD include a "(...)" style comment after the
2080 result, conveying supporting information for the result, such as
2081 <ip>, <sender>, and <domain>.
2084 SPF verifiers SHOULD give enough information so that the SPF results
2085 can be verified -- that is, at least "client-ip", "helo", and, if the
2086 "MAIL FROM" identity was checked, "envelope-from".
2088 client-ip the IP address of the SMTP client
2092 helo the host name given in the HELO or EHLO command
2094 mechanism the mechanism that matched (if no mechanisms matched,
2097 problem if an error was returned, details about the error
2099 receiver the host name of the SPF verifier
2101 identity the identity that was checked; see the <identity>
2104 Other keys MAY be defined by SPF verifiers.
2106 SPF verifiers MUST make sure that the Received-SPF header field does
2107 not contain invalid characters, is not excessively long (see
2108 [RFC5322], Section 2.1.1), and does not contain malicious data that
2109 has been provided by the sender.
2111 Examples of various header field styles that could be generated are
2114 Received-SPF: pass (mybox.example.org: domain of
2115 myname@example.com designates 192.0.2.1 as permitted sender)
2116 receiver=mybox.example.org; client-ip=192.0.2.1;
2117 envelope-from="myname@example.com"; helo=foo.example.com;
2119 Received-SPF: fail (mybox.example.org: domain of
2120 myname@example.com does not designate
2121 192.0.2.1 as permitted sender)
2122 identity=mailfrom; client-ip=192.0.2.1;
2123 envelope-from="myname@example.com";
2130Kitterman Standards Track [Page 38]
2132RFC 7208 Sender Policy Framework (SPF) April 2014
2135 Received-SPF: pass (mybox.example.org: domain of
2136 myname@example.com designates 192.0.2.1 as permitted sender)
2137 receiver=mybox.example.org; client-ip=192.0.2.1;
2138 mechanism=ip4:192.0.2.1; envelope-from="myname@example.com";
2139 helo=foo.example.com;
2143 As mentioned in Section 9, the Authentication-Results header field is
2144 designed to communicate lists of tests a border MTA did and their
2145 results. The specified elements of the field provide less
2146 information than the Received-SPF field:
2148 Authentication-Results: myhost.example.org; spf=pass
2149 smtp.mailfrom=example.net
2151 Received-SPF: pass (myhost.example.org: domain of
2152 myname@example.com designates 192.0.2.1 as permitted sender)
2153 receiver=mybox.example.org; client-ip=192.0.2.1;
2154 envelope-from="myname@example.com"; helo=foo.example.com;
2156 It is, however, possible to add CFWS in the "reason" part of an
2157 Authentication-Results header field and provide the equivalent
2158 information, if desired.
2160 As an example, an expanded Authentication-Results header field might
2161 look like (for a "MAIL FROM" check in this example):
2163 Authentication-Results: myhost.example.org; spf=pass
2164 reason="client-ip=192.0.2.1; smtp.helo=foo.example.com"
2165 smtp.mailfrom=user@example.net
2169 This section outlines the major implications that adoption of this
2170 protocol will have on various entities involved in Internet email.
2171 It is intended to make clear to the reader where this protocol
2172 knowingly affects the operation of such entities. This section is
2173 not a "how-to" manual, or a "best practices" document, and it is not
2174 a comprehensive list of what such entities ought to do in light of
2177 This section provides operational advice and instruction only. It is
2180 [RFC5598] describes the Internet email architecture. This section is
2181 organized based on the different segments of the architecture.
2186Kitterman Standards Track [Page 39]
2188RFC 7208 Sender Policy Framework (SPF) April 2014
219110.1. Sending Domains
2193 Originating ADMDs (ADministrative Management Domains --
2194 Sections 2.2.1 and 2.3 of [RFC5598]) that wish to be compliant with
2195 this specification will need to determine the list of relays
2196 ([RFC5598], Section 2.2.2) that they allow to use their domain name
2197 in the "HELO" and "MAIL FROM" identities when relaying to other
2198 ADMDs. It is recognized that forming such a list is not just a
2199 simple technical exercise, but involves policy decisions with both
2200 technical and administrative considerations.
220210.1.1. DNS Resource Considerations
2204 Minimizing the DNS resources needed for SPF lookups can be done by
2205 choosing directives that require less DNS information and by placing
2206 lower-cost mechanisms earlier in the SPF record.
2208 Section 4.6.4 specifies the limits receivers have to use. It is
2209 essential to publish records that do not exceed these requirements.
2210 It is also required to carefully weigh the cost and the
2211 maintainability of licit solutions.
2213 For example, consider a domain set up as follows:
2215 example.com. IN MX 10 mx.example.com.
2216 IN MX 20 mx2.example.com.
2217 mx.example.com. IN A 192.0.2.1
2218 mx2.example.com. IN A 192.0.2.129
2220 Assume the administrative point is to authorize (pass) mx and mx2
2221 while failing every other host. Compare the following solutions:
2224 example.com. IN TXT "v=spf1 ip4:192.0.2.1 ip4:192.0.2.129 -all"
2227 $ORIGIN example.com.
2228 @ IN TXT "v=spf1 a:authorized-spf.example.com -all"
2229 authorized-spf IN A 192.0.2.1
2233 example.com. IN TXT "v=spf1 mx:example.com -all"
2235 Wasteful, bad record:
2236 example.com. IN TXT "v=spf1 ip4:192.0.2.0/24 mx -all"
2242Kitterman Standards Track [Page 40]
2244RFC 7208 Sender Policy Framework (SPF) April 2014
224710.1.2. Administrator's Considerations
2249 There might be administrative considerations: using "a" over "ip4" or
2250 "ip6" allows hosts to be renumbered easily at the cost of a DNS query
2251 per receiver. Using "mx" over "a" allows the set of mail hosts to be
2252 changed easily. Unless such changes are common, it is better to use
2253 the less resource-intensive mechanisms like "ip4" and "ip6" over "a"
2256 In some specific cases, standard advice on record content is
2257 appropriate. Publishing SPF records for domains that send no mail is
2258 a well-established best practice. The record for a domain that sends
2261 www.example.com. IN TXT "v=spf1 -all"
2264 The host name is generally the identity used in the 5321.HELO/.EHLO
2265 command. In the case of messages with a null 5321.MailFrom, this is
2266 used as the domain for 5321.MailFrom SPF checks, in addition to being
2267 used in 5321.HELO/.EHLO-based SPF checks. The standard SPF record
2268 for an individual host that is involved in mail processing is:
2270 relay.example.com. IN TXT "v=spf1 a -all"
2272 Validating correct deployment is difficult. [RFC6652] describes one
2273 mechanism for soliciting feedback on SPF failures. Another
2274 suggestion can be found in Appendix C.
2276 Regardless of the method used, understanding the ADMD's outbound mail
2277 architecture is essential to effective deployment.
2281 As explained in Section 2.4, [RFC5321] allows the MAIL FROM to be
2282 null, which is typical of some Delivery Status Notifications
2283 [RFC3464], commonly called email bounces. In this case, the only
2284 entity available for performing an SPF check is the "HELO" identity
2285 defined in Section 1.1.4. SPF functionality is enhanced by
2286 administrators ensuring this identity is set correctly and has an
2288 to the host name instead of the domain. Zone file generation for
2289 significant numbers of hosts can be consolidated using the "redirect"
2290 modifier and scripted for initial deployment. Specific deployment
2291 advice is given above in Section 10.1.2.
2298Kitterman Standards Track [Page 41]
2300RFC 7208 Sender Policy Framework (SPF) April 2014
2305 SPF results can be used in combination with other methods to
2306 determine the final local disposition (either positive or negative)
2307 of a message. It can also be considered dispositive on its own.
2309 An attempt to have one organization (sender) direct the email-
2310 handling policies of another (receiver) is inherently challenging and
2311 often controversial. As stated elsewhere in this document, there is
2312 no comprehensive normative requirement for specific handling of a
2313 message based on SPF results. The information presented in Section 8
2314 and in Appendix G is offered for receiver consideration when forming
2315 local handling policies.
2317 The primary considerations are that SPF might return "pass" for mail
2318 that is ultimately harmful (e.g., spammers that arrange for SPF to
2319 pass using disposable domain names, or virus or spam outbreaks from
2320 within trusted sources), and might also return "fail" for mail that
2321 is ultimately legitimate (e.g., legitimate mail that has traversed a
2322 mail alias). It is important to take both of these cases under
2323 consideration when establishing local handling policy.
2327 Mediators are a type of User Actor [RFC5598]. That is, a mediator
2328 takes 'delivery' of a message and posts a 'submission' of a new
2329 message. The mediator can make the newly posted message be as
2330 similar to or as different from the original message as they wish.
2331 Examples include mailing lists (see Section 5.3 of [RFC5598]) and
2332 ReSenders (Section 5.2 of [RFC5598]). This is discussed in
2333 [RFC5321], Section 3.9. For the operation of SPF, the essential
2334 concern is the email address in the 5321.MailFrom command for the new
2337 Because SPF evaluation is based on the IP address of the "last"
2338 sending SMTP server, the address of the mediator will be used, rather
2339 than the address of the SMTP server that sent the message to the
2340 mediator. Some mediators retain the email address from the original
2341 message, while some use a new address.
2343 If the address is the same as for the original message, and the
2344 original message had an associated SPF record, then the SPF
2345 evaluation will fail unless mitigations such as those described in
2346 Appendix D are used.
2354Kitterman Standards Track [Page 42]
2356RFC 7208 Sender Policy Framework (SPF) April 2014
235911. Security Considerations
236111.1. Processing Limits
2363 As with most aspects of email, there are a number of ways that
2364 malicious parties could use the protocol as an avenue for a DoS
2365 attack. The processing limits outlined in Section 4.6.4 are designed
2366 to prevent attacks such as the following:
2368 o A malicious party could create an SPF record with many references
2369 to a victim's domain and send many emails to different SPF
2370 verifiers; those SPF verifiers would then create a DoS attack. In
2371 effect, the SPF verifiers are being used to amplify the attacker's
2372 bandwidth by using fewer octets in the SMTP session than are used
2373 by the DNS queries. Using SPF verifiers also allows the attacker
2374 to hide the true source of the attack. This potential attack is
2375 based on large volumes of mail being transmitted.
2377 o Whereas implementations of check_host() are supposed to limit the
2378 number of DNS lookups, malicious domains could publish records
2379 that exceed these limits in an attempt to waste computation effort
2380 at their targets when they send them mail. Malicious domains
2381 could also design SPF records that cause particular
2382 implementations to use excessive memory or CPU or to trigger bugs.
2383 If a receiver is configured to accept mail with an SPF result of
2384 "temperror", such an attack might result in mail that would
2385 otherwise have been rejected due to an SPF "fail" result being
2386 accepted. This potential attack is based on specially crafted SPF
2387 records being used to exhaust DNS resources of the victim.
2389 o Malicious parties could send a large volume of mail purporting to
2390 come from the intended target to a wide variety of legitimate mail
2391 hosts. These legitimate machines would then present a DNS load on
2392 the target as they fetched the relevant records.
2394 o Malicious parties could, in theory, use SPF records as a vehicle
2395 for DNS lookup amplification for a DoS attack. In this scenario,
2396 the attacker publishes an SPF record in its own DNS that uses "a"
2397 and "mx" mechanisms directed toward the intended victim, e.g.,
2398 "a:example.com a:foo.example.com a:bar.example.com ..." and then
2399 distributes mail with a MAIL FROM value including its own domain
2400 in large volume to a wide variety of destinations. Any such
2401 destination operating an SPF verifier will begin querying all of
2402 the names associated with the "a" mechanisms in that record. The
2403 names used in the record needn't exist for the attack to be
2404 effective. Operational experience since the publication of
2405 [RFC4408] suggests that mitigation of this class of attack can be
2406 accomplished with minimal impact on the deployed base by having
2410Kitterman Standards Track [Page 43]
2412RFC 7208 Sender Policy Framework (SPF) April 2014
2415 the verifier abort processing and return "permerror"
2416 (Section 2.6.7) as soon as more than two "void lookups" have been
2417 encountered (defined in Section 4.6.4).
2419 Of these, the case of a third party referenced in the SPF record is
2420 the easiest for a DoS attack to effectively exploit. As a result,
2421 limits that might seem reasonable for an individual mail server can
2422 still allow an unreasonable amount of bandwidth amplification.
2423 Therefore, the processing limits need to be quite low.
242511.2. SPF-Authorized Email May Contain Other False Identities
2427 The "MAIL FROM" and "HELO" identity authorizations do not provide
2428 assurance about the authorization/authenticity of other identities
2429 used in the message. It is entirely possible for a malicious sender
2430 to inject a message using his own domain in the identities used by
2431 SPF and have that domain's SPF record authorize the sending host, and
2432 yet the message can easily list other identities in its header.
2433 Unless the user or the MUA takes care to note that the authorized
2434 identity does not match the other more commonly presented identities
2435 (such as the From: header field), the user might be lulled into a
2436 false sense of security.
243811.3. Spoofed DNS and IP Data
2440 There are two aspects of this protocol that malicious parties could
2441 exploit to undermine the validity of the check_host() function:
2443 o The evaluation of check_host() relies heavily on DNS. A malicious
2444 attacker could attack the DNS infrastructure and cause
2445 check_host() to see spoofed DNS data, and then return incorrect
2446 results. This could include returning "pass" for an <ip> value
2447 where the actual domain's record would evaluate to "fail". See
2448 [RFC3833] for a description of DNS weaknesses, and see [RFC4033]
2449 for a countermeasure.
2451 o The client IP address, <ip>, is assumed to be correct. In a
2452 modern, correctly configured system, the risk of this not being
245511.4. Cross-User Forgery
2457 By definition, SPF policies just map domain names to sets of
2458 authorized MTAs, not whole email addresses to sets of authorized
2459 users. Although the "l" macro (Section 7) provides a limited way to
2460 define individual sets of authorized MTAs for specific email
2461 addresses, it is generally impossible to verify, through SPF, the use
2462 of specific email addresses by individual users of the same MTA.
2466Kitterman Standards Track [Page 44]
2468RFC 7208 Sender Policy Framework (SPF) April 2014
2471 It is up to mail services and their MTAs to directly prevent
2472 cross-user forgery: based on SMTP AUTH ([RFC4954]), users have to be
2473 restricted to using only those email addresses that are actually
2474 under their control (see Section 6.1 of [RFC6409]). Another means to
2475 verify the identity of individual users is message cryptography, such
2476 as Pretty Good Privacy (PGP) ([RFC4880]) or S/MIME ([RFC5751]).
247811.5. Untrusted Information Sources
2480 An SPF-compliant receiver gathers information from the SMTP commands
2481 it receives and from the published DNS records of the sending domain
2482 holder (e.g., "HELO" domain name, the "MAIL FROM" address from the
2483 envelope, and SPF DNS records published by the domain holder). These
2484 parameters are not validated in the SMTP process.
2486 All of these pieces of information are generated by actors outside of
2487 the authority of the receiver, and thus are not guaranteed to be
2488 accurate or legitimate.
249011.5.1. Recorded Results
2492 This information, passed to the receiver in the Received-SPF: or
2493 Authentication-Results: trace fields, can be returned to the client
2494 MTA as an SMTP rejection message. If such an SMTP rejection message
2495 is generated, the information from the trace fields has to be checked
2496 for such problems as invalid characters and excessively long lines.
249811.5.2. External Explanations
2500 When the authorization check fails, an explanation string could be
2501 included in the reject response. Both the sender and the rejecting
2502 receiver need to be aware that the explanation was determined by the
2503 publisher of the SPF record checked and, in general, not the
2504 receiver. The explanation can contain malicious URLs, or it might be
2505 offensive or misleading.
2507 Explanations returned to sender domains due to "exp" modifiers
2508 (Section 6.2) were generated by the sender policy published by the
2509 domain holders themselves. As long as messages are only returned
2510 with non-delivery notifications ([RFC3464]) to domains publishing the
2511 explanation strings from their own DNS SPF records, the only affected
2512 parties are the original publishers of the domain's SPF records.
2514 In practice, such non-delivery notifications can be misdirected, such
2515 as when an MTA accepts an email and only later generates the
2516 notification to a forged address, or when an email forwarder does not
2517 direct the bounce back to the original sender.
2522Kitterman Standards Track [Page 45]
2524RFC 7208 Sender Policy Framework (SPF) April 2014
252711.5.3. Macro Expansion
2530 non-null [US-ASCII] character) into receiver DNS queries. It is
2531 necessary to be prepared for hostile or unexpected content.
253311.6. Privacy Exposure
2535 Checking SPF records causes DNS queries to be sent to the domain
2536 owner. These DNS queries, especially if they are caused by the
2537 "exists" mechanism, can contain information about who is sending
2538 email and likely to which MTA the email is being sent. This can
2539 introduce some privacy concerns, which are more or less of an issue
2540 depending on local laws and the relationship between the ADMD and the
2541 person sending the email.
254311.7. Delivering Mail Producing a "Fail" Result
2545 Operators that choose to deliver mail for which SPF produces a "fail"
2546 result need to understand that they are admitting content that is
2547 explicitly not authorized by the purported sender. While there are
2548 known failure modes that can be considered "false negatives", the
2549 distinct choice to admit those messages increases end-user exposure
2550 to likely harm. This is especially true for domains belonging to
2551 known good actors that are typically well-behaved; unauthorized mail
2552 from those sources might well be subjected to much higher skepticism
2553 and content analysis.
2555 SPF does not, however, include the capacity to distinguish good
2556 actors from bad ones, nor does it handle the concept of known actors
2557 versus unknown ones. Those notions are out of scope for this
2562 This section is normative, and any discrepancies with the ABNF
2563 fragments in the preceding text are to be resolved in favor of this
2566 See [RFC5234] for ABNF notation. Please note that as per this ABNF
2567 definition, literal text strings (those in quotes) are case-
2568 insensitive. Hence, "mx" matches "mx", "MX", "mX", and "Mx".
2570 record = version terms *SP
2573 terms = *( 1*SP ( directive / modifier ) )
2578Kitterman Standards Track [Page 46]
2580RFC 7208 Sender Policy Framework (SPF) April 2014
2583 directive = [ qualifier ] mechanism
2584 qualifier = "+" / "-" / "?" / "~"
2586 / a / mx / ptr / ip4 / ip6 / exists )
2589 include = "include" ":" domain-spec
2590 a = "a" [ ":" domain-spec ] [ dual-cidr-length ]
2591 mx = "mx" [ ":" domain-spec ] [ dual-cidr-length ]
2592 ptr = "ptr" [ ":" domain-spec ]
2593 ip4 = "ip4" ":" ip4-network [ ip4-cidr-length ]
2594 ip6 = "ip6" ":" ip6-network [ ip6-cidr-length ]
2595 exists = "exists" ":" domain-spec
2598 redirect = "redirect" "=" domain-spec
2599 explanation = "exp" "=" domain-spec
2601 ; where name is not any known modifier
2603 ip4-cidr-length = "/" ("0" / %x31-39 0*1DIGIT) ; value range 0-32
2604 ip6-cidr-length = "/" ("0" / %x31-39 0*2DIGIT) ; value range 0-128
2605 dual-cidr-length = [ ip4-cidr-length ] [ "/" ip6-cidr-length ]
2609 / %x31-39 DIGIT ; 10-99
2610 / "1" 2DIGIT ; 100-199
2611 / "2" %x30-34 DIGIT ; 200-249
2612 / "25" %x30-35 ; 250-255
2613 ; conventional dotted-quad notation, e.g., 192.0.2.0
2615 ; e.g., 2001:db8::cd30
2617 domain-spec = macro-string domain-end
2618 domain-end = ( "." toplabel [ "." ] ) / macro-expand
2620 toplabel = ( *alphanum ALPHA *alphanum ) /
2621 ( 1*alphanum "-" *( alphanum / "-" ) alphanum )
2622 ; LDH rule plus additional TLD restrictions
2623 ; (see Section 2 of [RFC3696] for background)
2624 alphanum = ALPHA / DIGIT
2626 explain-string = *( macro-string / SP )
2628 macro-string = *( macro-expand / macro-literal )
2629 macro-expand = ( "%{" macro-letter transformers *delimiter "}" )
2630 / "%%" / "%_" / "%-"
2634Kitterman Standards Track [Page 47]
2636RFC 7208 Sender Policy Framework (SPF) April 2014
2639 macro-literal = %x21-24 / %x26-7E
2640 ; visible characters except "%"
2641 macro-letter = "s" / "l" / "o" / "d" / "i" / "p" / "h" /
2642 "c" / "r" / "t" / "v"
2643 transformers = *DIGIT [ "r" ]
2644 delimiter = "." / "-" / "+" / "," / "/" / "_" / "="
2646 name = ALPHA *( ALPHA / DIGIT / "-" / "_" / "." )
2648 header-field = "Received-SPF:" [CFWS] result FWS [comment FWS]
2649 [ key-value-list ] CRLF
2651 result = "pass" / "fail" / "softfail" / "neutral" /
2652 "none" / "temperror" / "permerror"
2654 key-value-list = key-value-pair *( ";" [CFWS] key-value-pair )
2657 key-value-pair = key [CFWS] "=" ( dot-atom / quoted-string )
2659 key = "client-ip" / "envelope-from" / "helo" /
2660 "problem" / "receiver" / "identity" /
2663 identity = "mailfrom" ; for the "MAIL FROM" identity
2664 / "helo" ; for the "HELO" identity
2665 / name ; other identities
2668 ip = ip4-network / ip6-network
2669 ALPHA = <A-Z / a-z as per [RFC5234]>
2670 DIGIT = <0-9 as per [RFC5234]>
2671 SP = <space character as per [RFC5234]>
2672 dot-atom = <unquoted word as per [RFC5322]>
2673 quoted-string = <quoted string as per [RFC5322]>
2674 comment = <comment string as per [RFC5322]>
2675 CFWS = <comment or folding white space as per [RFC5322]>
2676 FWS = <folding white space as per [RFC5322]>
2677 CRLF = <standard end-of-line token as per [RFC5322]>
267913. Contributors and Acknowledgements
2681 This document is largely based on the work of Meng Weng Wong, Mark
2682 Lentczner, and Wayne Schlitt. Although, as this section
2683 acknowledges, many people have contributed to this document, a very
2684 large portion of the writing and editing is due to Meng, Mark, and
2690Kitterman Standards Track [Page 48]
2692RFC 7208 Sender Policy Framework (SPF) April 2014
2695 This design owes a debt of parentage to [RMX] by Hadmut Danisch and
2696 to [DMP] by Gordon Fecyk. The idea of using a DNS record to check
2697 the legitimacy of an email address traces its ancestry further back
2698 through messages on the namedroppers mailing list by Paul Vixie
2699 [Vixie] (based on suggestion by Jim Miller) and by David Green
2702 Philip Gladstone contributed the concept of macros to the
2703 specification, multiplying the expressiveness of the language and
2704 making per-user and per-IP lookups possible.
2706 The authors of both this document and [RFC4408] would also like to
2707 thank the literally hundreds of individuals who have participated in
2708 the development of this design. They are far too numerous to name,
2709 but they include the following:
2711 The participants in the SPFbis working group. The folks on the
2712 spf-discuss mailing list. The folks on the SPAM-L mailing list.
2713 The folks on the IRTF ASRG mailing list. The folks on the IETF
2714 MARID mailing list. The folks on #perl.
271614. IANA Considerations
271814.1. The SPF DNS Record Type
2720 Per [RFC4408], the IANA assigned the Resource Record Type and Qtype
2721 from the "Domain Name System (DNS) Parameters" registry for the SPF
2722 RR type with code 99. The format of this type is identical to the
2723 TXT RR [RFC1035]. The character content of the record is encoded as
2726 Studies have shown that RRTYPE 99 has not seen any substantial use,
2727 and in fact its existence and mechanism defined in [RFC4408] have led
2728 to some interoperability issues. Accordingly, its use is no longer
2729 appropriate for SPF version 1; implementations are not to use it.
2731 IANA has updated the "Resource Record (RR) TYPEs" registry to
2732 indicate that this document is the reference document for that
2746Kitterman Standards Track [Page 49]
2748RFC 7208 Sender Policy Framework (SPF) April 2014
275114.2. The Received-SPF Mail Header Field
2753 Per [RFC3864], the "Received-SPF:" header field is added to the IANA
2754 "Permanent Message Header Field Names" registry. The following is
2755 the registration template:
2757 Header field name: Received-SPF Applicable protocol: mail
2758 ([RFC5322]) Status: standard Author/Change controller: IETF
2759 Specification document(s): RFC 7208
276114.3. SPF Modifier Registry
2763 IANA has changed the reference for the "exp" and "redirect" modifiers
2764 in the "Modifier Names" registry, under Sender Policy Framework
2765 Parameters, from [RFC4408] to this document. Their status is
277015.1. Normative References
2772 [RFC1035] Mockapetris, P., "Domain names - implementation and
2773 specification", STD 13, RFC 1035, November 1987.
2775 [RFC1123] Braden, R., "Requirements for Internet Hosts - Application
2776 and Support", STD 3, RFC 1123, October 1989.
2778 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
2779 Requirement Levels", BCP 14, RFC 2119, March 1997.
2781 [RFC3463] Vaudreuil, G., "Enhanced Mail System Status Codes",
2782 RFC 3463, January 2003.
2784 [RFC3864] Klyne, G., Nottingham, M., and J. Mogul, "Registration
2785 Procedures for Message Header Fields", BCP 90, RFC 3864,
2788 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform
2789 Resource Identifier (URI): Generic Syntax", STD 66,
2790 RFC 3986, January 2005.
2792 [RFC4291] Hinden, R. and S. Deering, "IP Version 6 Addressing
2793 Architecture", RFC 4291, February 2006.
2795 [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax
2796 Specifications: ABNF", STD 68, RFC 5234, January 2008.
2802Kitterman Standards Track [Page 50]
2804RFC 7208 Sender Policy Framework (SPF) April 2014
2807 [RFC5321] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321,
2810 [RFC5322] Resnick, P., Ed., "Internet Message Format", RFC 5322,
2813 [RFC5598] Crocker, D., "Internet Mail Architecture", RFC 5598,
2816 [RFC5890] Klensin, J., "Internationalized Domain Names for
2817 Applications (IDNA): Definitions and Document Framework",
2818 RFC 5890, August 2010.
2820 [RFC7001] Kucherawy, M., "Message Header Field for Indicating
2821 Message Authentication Status", RFC 7001, September 2013.
2824 American National Standards Institute (formerly United
2825 States of America Standards Institute), "USA Code for
2826 Information Interchange, X3.4", 1968.
2828 ANSI X3.4-1968 has been replaced by newer versions with
2829 slight modifications, but the 1968 version remains
2830 definitive for the Internet.
283215.2. Informative References
2834 [BATV] Levine, J., Crocker, D., Silberman, S., and T. Finch,
2835 "Bounce Address Tag Validation (BATV)", Work in Progress,
2838 [DMP] Fecyk, G., "Designated Mailers Protocol", Work in
2841 [Green] Green, D., "Domain-Authorized SMTP Mail", June 2002,
2842 <http://www.mhonarc.org/archive/html/ietf-asrg/2003-03/
2845 [RFC1034] Mockapetris, P., "Domain names - concepts and facilities",
2846 STD 13, RFC 1034, November 1987.
2848 [RFC1983] Malkin, G., "Internet Users' Glossary", RFC 1983,
2851 [RFC2308] Andrews, M., "Negative Caching of DNS Queries (DNS
2852 NCACHE)", RFC 2308, March 1998.
2858Kitterman Standards Track [Page 51]
2860RFC 7208 Sender Policy Framework (SPF) April 2014
2863 [RFC2671] Vixie, P., "Extension Mechanisms for DNS (EDNS0)",
2864 RFC 2671, August 1999.
2866 [RFC2782] Gulbrandsen, A., Vixie, P., and L. Esibov, "A DNS RR for
2867 specifying the location of services (DNS SRV)", RFC 2782,
2870 [RFC3464] Moore, K. and G. Vaudreuil, "An Extensible Message Format
2871 for Delivery Status Notifications", RFC 3464,
2874 [RFC3696] Klensin, J., "Application Techniques for Checking and
2875 Transformation of Names", RFC 3696, February 2004.
2877 [RFC3833] Atkins, D. and R. Austein, "Threat Analysis of the Domain
2878 Name System (DNS)", RFC 3833, August 2004.
2880 [RFC3834] Moore, K., "Recommendations for Automatic Responses to
2881 Electronic Mail", RFC 3834, August 2004.
2883 [RFC4033] Arends, R., Austein, R., Larson, M., Massey, D., and S.
2884 Rose, "DNS Security Introduction and Requirements",
2885 RFC 4033, March 2005.
2887 [RFC4408] Wong, M. and W. Schlitt, "Sender Policy Framework (SPF)
2888 for Authorizing Use of Domains in E-Mail, Version 1",
2889 RFC 4408, April 2006.
2891 [RFC4632] Fuller, V. and T. Li, "Classless Inter-domain Routing
2892 (CIDR): The Internet Address Assignment and Aggregation
2893 Plan", BCP 122, RFC 4632, August 2006.
2895 [RFC4880] Callas, J., Donnerhacke, L., Finney, H., Shaw, D., and R.
2896 Thayer, "OpenPGP Message Format", RFC 4880, November 2007.
2898 [RFC4954] Siemborski, R. and A. Melnikov, "SMTP Service Extension
2899 for Authentication", RFC 4954, July 2007.
2901 [RFC5507] IAB, Faltstrom, P., Austein, R., and P. Koch, "Design
2902 Choices When Expanding the DNS", RFC 5507, April 2009.
2904 [RFC5751] Ramsdell, B. and S. Turner, "Secure/Multipurpose Internet
2905 Mail Extensions (S/MIME) Version 3.2 Message
2906 Specification", RFC 5751, January 2010.
2908 [RFC5782] Levine, J., "DNS Blacklists and Whitelists", RFC 5782,
2914Kitterman Standards Track [Page 52]
2916RFC 7208 Sender Policy Framework (SPF) April 2014
2919 [RFC6409] Gellens, R. and J. Klensin, "Message Submission for Mail",
2920 STD 72, RFC 6409, November 2011.
2922 [RFC6647] Kucherawy, M. and D. Crocker, "Email Greylisting: An
2923 Applicability Statement for SMTP", RFC 6647, June 2012.
2925 [RFC6648] Saint-Andre, P., Crocker, D., and M. Nottingham,
2926 "Deprecating the "X-" Prefix and Similar Constructs in
2927 Application Protocols", BCP 178, RFC 6648, June 2012.
2929 [RFC6652] Kitterman, S., "Sender Policy Framework (SPF)
2930 Authentication Failure Reporting Using the Abuse Reporting
2931 Format", RFC 6652, June 2012.
2933 [RFC6686] Kucherawy, M., "Resolution of the Sender Policy Framework
2934 (SPF) and Sender ID Experiments", RFC 6686, July 2012.
2936 [RFC6891] Damas, J., Graff, M., and P. Vixie, "Extension Mechanisms
2937 for DNS (EDNS(0))", STD 75, RFC 6891, April 2013.
2939 [RMX] Danisch, H., "The RMX DNS RR and method for lightweight
2940 SMTP sender authorization", Work in Progress, May 2004.
2942 [Vixie] Vixie, P., "Repudiating MAIL FROM", 2002,
2943 <http://marc.info/?l=namedroppers&m=102298170127004&w=4>.
2970Kitterman Standards Track [Page 53]
2972RFC 7208 Sender Policy Framework (SPF) April 2014
2977 These examples are based on the following DNS setup:
2979 ; A domain with two mail servers, two hosts, and two servers
2980 ; at the domain name
2981 $ORIGIN example.com.
2988 mail-a A 192.0.2.129
2989 mail-b A 192.0.2.130
2990 www CNAME example.com.
2993 $ORIGIN example.org.
2995 mail-c A 192.0.2.140
2997 ; The reverse IP for those addresses
2998 $ORIGIN 2.0.192.in-addr.arpa.
3001 65 PTR amy.example.com.
3002 66 PTR bob.example.com.
3003 129 PTR mail-a.example.com.
3004 130 PTR mail-b.example.com.
3005 140 PTR mail-c.example.org.
3007 ; A rogue reverse IP domain that claims to be
3008 ; something it's not
3009 $ORIGIN 0.0.10.in-addr.arpa.
3010 4 PTR bob.example.com.
3026Kitterman Standards Track [Page 54]
3028RFC 7208 Sender Policy Framework (SPF) April 2014
3033 These examples show various possible published records for
3034 example.com and which values of <ip> would cause check_host() to
3035 return "pass". Note that <domain> is "example.com".
3043 -- hosts 192.0.2.10 and 192.0.2.11 pass
3045 v=spf1 a:example.org -all
3047 -- no sending hosts pass since example.org has no A records
3051 -- sending hosts 192.0.2.129 and 192.0.2.130 pass
3053 v=spf1 mx:example.org -all
3055 -- sending host 192.0.2.140 passes
3057 v=spf1 mx mx:example.org -all
3059 -- sending hosts 192.0.2.129, 192.0.2.130, and 192.0.2.140 pass
3061 v=spf1 mx/30 mx:example.org/30 -all
3063 -- any sending host in 192.0.2.128/30 or 192.0.2.140/30 passes
3067 -- sending host 192.0.2.65 passes (reverse DNS is valid and is
3070 -- sending host 192.0.2.140 fails (reverse DNS is valid, but not
3073 -- sending host 10.0.0.4 fails (reverse IP is not valid)
3082Kitterman Standards Track [Page 55]
3084RFC 7208 Sender Policy Framework (SPF) April 2014
3087 v=spf1 ip4:192.0.2.128/28 -all
3089 -- sending host 192.0.2.65 fails
3091 -- sending host 192.0.2.129 passes
3095 These examples show the effect of related records:
3097 example.org: "v=spf1 include:example.com include:example.net -all"
3099 This record would be used if mail from example.org actually came
3100 through servers at example.com and example.net. Example.org's
3101 designated servers are the union of example.com's and example.net's
3104 la.example.org: "v=spf1 redirect=example.org"
3106 ny.example.org: "v=spf1 redirect=example.org"
3108 sf.example.org: "v=spf1 redirect=example.org"
3110 These records allow a set of domains that all use the same mail
3111 system to make use of that mail system's record. In this way, only
3112 the mail system's record needs to be updated when the mail setup
3113 changes. These domains' records never have to change.
3117 Imagine that, in addition to the domain records listed above, there
3118 are these (see [RFC5782]):
3120 $ORIGIN _spf.example.com.
3121 mary.mobile-users A 127.0.0.2
3122 fred.mobile-users A 127.0.0.2
3123 15.15.168.192.joel.remote-users A 127.0.0.2
3124 16.15.168.192.joel.remote-users A 127.0.0.2
3138Kitterman Standards Track [Page 56]
3140RFC 7208 Sender Policy Framework (SPF) April 2014
3143 The following records describe users at example.com who mail from
3144 arbitrary servers, or who mail from personal servers.
3149 include:mobile-users._spf.%{d}
3150 include:remote-users._spf.%{d}
3153 mobile-users._spf.example.com:
3155 v=spf1 exists:%{l1r+}.%{d}
3157 remote-users._spf.example.com:
3159 v=spf1 exists:%{ir}.%{l1r+}.%{d}
3161A.4. Multiple Requirements Example
3163 Say that your sender policy requires both that the IP address is
3164 within a certain range and that the reverse DNS for the IP matches.
3165 This can be done several ways, including the following:
3167 example.com. SPF ( "v=spf1 "
3168 "-include:ip4._spf.%{d} "
3169 "-include:ptr._spf.%{d} "
3174 This example shows how the "-include" mechanism can be useful, how an
3175 SPF record that ends in "+all" can be very restrictive, and the use
3178Appendix B. Changes in Implementation Requirements from RFC 4408
3180 The modifications to implementation requirements from [RFC4408] are
3181 all either (a) corrections to errors in [RFC4408] or (b) additional
3182 documentation based on consensus of operational experience acquired
3183 since the publication of [RFC4408].
3185 o Use of DNS RR type SPF (99) has been removed from the protocol;
3186 see [RFC6686] for background.
3188 o A new DNS-related processing limit based on "void lookups" has
3189 been added (Section 4.6.4).
3194Kitterman Standards Track [Page 57]
3196RFC 7208 Sender Policy Framework (SPF) April 2014
3199 o Use of the ptr mechanism and the %p macro has been strongly
3200 discouraged (Sections 5.5 and 7.2). The ptr mechanism and the %p
3201 macro remain part of the protocol because they were found to be in
3202 use, but records ought to be updated to avoid them.
3204 o Use of the "Authentication-Results" header field [RFC7001] as a
3205 possible alternative to use of the "Received-SPF" header field is
3206 discussed (Section 9.2).
3208 o There have been a number of minor corrections to the ABNF to make
3209 it more clear and correct (Section 12). SPF library implementers
3210 should give the revised ABNF a careful review to determine if
3211 implementation changes are needed.
3213 o Use of X- fields in the ABNF has been removed; see [RFC6648] for
3216 o Ambiguity about how to deal with invalid <domain-spec> after macro
3217 expansion has been documented. Depending on one specific behavior
3218 has to be avoided (Section 4.8).
3220 o General operational information has been updated and expanded
3221 based on eight years of post-[RFC4408] operations experience. See
3222 Section 10 and Appendices D through G below.
3224 o Security considerations have been reviewed and updated
3227Appendix C. Further Testing Advice
3229 Another approach that can be helpful is to publish records that
3230 include a "tracking exists:" mechanism. By looking at the name
3231 server logs, a rough list can then be generated. For example:
3233 v=spf1 exists:_h.%{h}._l.%{l}._o.%{o}._i.%{i}._spf.%{d} ?all
3235 This associated macro expansion would cause the sending HELO domain,
3236 local-part of the sending email address, domain part of the sending
3237 email address, and the IP address from which the connection was
3238 received to be embedded in an SPF query and logged in the sender's
3241 This approach, which has been used since very early in the SPF
3242 project, allows senders to unilaterally collect data to evaluate the
3243 correctness of their SPF records. Unlike newer feedback mechanisms,
3244 it does not require any special cooperation from SPF verifiers. A
3245 similar example, one of the earliest SPF records published, can still
3246 be found as of this writing at altavista.net.
3250Kitterman Standards Track [Page 58]
3252RFC 7208 Sender Policy Framework (SPF) April 2014
3255Appendix D. SPF/Mediator Interactions
3257 There are three places that techniques can be used to ameliorate
3258 unintended SPF failures with mediators.
3260D.1. Originating ADMDs
3262 The beginning, when email is first sent:
3264 o "Neutral" results could be given for IP addresses that might be
3265 forwarders, instead of "fail" results based on a list of known
3266 reliable forwarders. For example:
3268 "v=spf1 mx ?exists:%{ir}.whitelist.example.org -all"
3270 This would cause a lookup on a DNS White List (DNSWL) and cause a
3271 result of "fail" only for email not coming from either the
3272 domain's mx host(s) (SPF pass) or whitelisted sources (SPF
3273 neutral). This, in effect, outsources an element of sender policy
3274 to the maintainer of the whitelist.
3276 o The "MAIL FROM" identity could have additional information in the
3277 local-part that cryptographically identifies the mail as coming
3278 from an authorized source. In this case, an SPF record such as
3279 the following could be used:
3281 "v=spf1 mx exists:%{l}._spf_verify.%{d} -all"
3283 Then, a specialized DNS server can be set up to serve the
3284 _spf_verify subdomain that validates the local-part. Although
3285 this requires an extra DNS lookup, this happens only when the
3286 email would otherwise be rejected as not coming from a known good
3289 Note that due to the 63-character limit for domain labels, this
3290 approach only works reliably if the local-part signature scheme is
3291 guaranteed to either only produce local-parts with a maximum of
3292 63 characters or gracefully handle truncated local-parts. The
3293 method used to secure the local-part is a local implementation
3294 issue; it need not be standard. An example of one way to do it
3295 can be found in [BATV].
3297 o Similarly, a specialized DNS server could be set up that will
3298 rate-limit the email coming from unexpected IP addresses.
3300 "v=spf1 mx exists:%{ir}._spf_rate.%{d} -all"
3306Kitterman Standards Track [Page 59]
3308RFC 7208 Sender Policy Framework (SPF) April 2014
3311 o SPF allows the creation of per-user policies for special cases.
3312 For example, the following SPF record and appropriate wildcard DNS
3313 records can be used:
3315 "v=spf1 mx redirect=%{l1r+}._at_.%{o}._spf.%{d}"
3319 The middle, when email is forwarded:
3321 o Mediators can solve the problem by rewriting the "MAIL FROM" to be
3322 in their own domain. This means mail rejected from the external
3323 mailbox will have to be forwarded back to the original sender by
3324 the forwarding service. Various schemes to do this exist, though
3325 they vary widely in complexity and resource requirements on the
3326 part of the mediator.
3328 o Several popular MTAs can be forced from "alias" semantics to
3329 "mailing list" semantics by configuring an additional alias with
3330 "owner-" prepended to the original alias name (e.g., an alias of
3331 "friends: george@example.com, fred@example.org" would need another
3332 alias of the form "owner-friends: localowner").
3334 o Mediators could reject mail that would "fail" SPF if forwarded
3335 using an SMTP reply code of 551, User not local (see Section 3.4
3336 of [RFC5321]) to communicate the correct target address to resend
3341 The end, when email is received:
3343 o If the owner of the external mailbox wishes to trust the mediator,
3344 he can direct the external mailbox's MTA to skip SPF tests when
3345 the client host belongs to the mediator.
3347 o Tests against other identities, such as the "HELO" identity, can
3348 be used to override a failed test against the "MAIL FROM"
3351 o For larger domains, it might not be possible to have a complete or
3352 accurate list of forwarding services used by the owners of the
3353 domain's mailboxes. In such cases, whitelists of generally
3354 recognized forwarding services could be employed.
3362Kitterman Standards Track [Page 60]
3364RFC 7208 Sender Policy Framework (SPF) April 2014
3367Appendix E. Mail Services
3369 MSPs (Mail Service Providers -- Section 2.3 of [RFC5598]) that offer
3370 mail services to third-party domains, such as the sending of bulk
3371 mail, might want to adjust their configurations in light of the
3372 authorization check described in this document. If the domain part
3373 of the "MAIL FROM" identity used for such email uses one of the MSP's
3374 domains, then the provider needs only to ensure that its sending host
3375 is authorized by its own SPF record, if any.
3377 If the "MAIL FROM" identity does not use the MSP's domain, then extra
3378 care has to be taken. The SPF record format has several options for
3379 the third-party domain to authorize the service provider's MTAs to
3380 send mail on its behalf. For MSPs, such as ISPs, that have a wide
3381 variety of customers using the same MTA, steps are required to
3382 mitigate the risk of cross-customer forgery (see Section 11.4).
3384Appendix F. MTA Relays
3386 Relays are described in [RFC5598], Section 2.2.2. The authorization
3387 check generally precludes the use of arbitrary MTA relays between the
3388 sender and receiver of an email message.
3390 Within an organization, MTA relays can be effectively deployed.
3391 However, for the purposes of this document, such relays are
3392 effectively transparent. The SPF authorization check is a check
3393 between border MTAs of different ADMDs.
3395 For mail senders, this means published SPF records have to authorize
3396 any MTAs that actually send across the Internet. Usually, these are
3397 just the border MTAs as internal MTAs simply forward mail to these
3400 The receiving ADMD will generally want to perform the authorization
3401 check at the boundary MTAs, including all secondary MXs. Internal
3402 MTAs (including MTAs that might serve as both boundary MTAs and
3403 internal relays from secondary MXs when they are processing the
3404 relayed mail stream) then do not perform the authorization test. To
3405 perform the authorization test other than at the boundary, the host
3406 that first transferred the message to the receiving ADMD has to be
3407 determined, which can be difficult to extract from the message header
3408 because (a) header fields can be forged or malformed, and (b) there's
3409 no standard way to encode that information such that it can be
3410 reliably extracted. Testing other than at the boundary is likely to
3411 produce unreliable results. This is described further in Appendix D
3418Kitterman Standards Track [Page 61]
3420RFC 7208 Sender Policy Framework (SPF) April 2014
3423Appendix G. Local Policy Considerations
3425 SPF results can be used in combination with other methods to
3426 determine the final local disposition (either positive or negative)
3427 of a message. It can also be considered dispositive on its own.
3429G.1. Policy for SPF Pass
3431 SPF "pass" results can be used in combination with "whitelists" of
3432 known "good" domains to bypass some or all additional pre-delivery
3433 email checks. Exactly which checks and how to determine appropriate
3434 whitelist entries have to be based on local conditions and
3437G.2. Policy for SPF Fail
3439 SPF "fail" results can be used to reject messages during the SMTP
3440 transaction based on either "MAIL FROM" or "HELO" identity results.
3441 This reduces resource requirements for various content-filtering
3442 methods and conserves bandwidth since rejection can be done before
3443 the SMTP content is transferred. It also gives immediate feedback to
3444 the sender, who might then be able to resolve the issue. Due to some
3445 of the issues described in this section (Appendix G), SPF-based
3446 rejection does present some risk of rejecting legitimate email when
3447 rejecting email based on "MAIL FROM" results.
3449 SPF "fail" results can alternately be used as one input into a larger
3450 set of evaluations that might, based on a combination of SPF "fail"
3451 results with other evaluation techniques, result in the email being
3452 marked negatively in some way (this might be via delivery to a
3453 special spam folder, modifying subject lines, or other locally
3454 determined means). Developing the details of such an approach has to
3455 be based on local conditions and requirements. Using SPF results in
3456 this way does not have the advantages of resource conservation and
3457 immediate feedback to the sender associated with SMTP rejection, but
3458 could produce fewer undesirable rejections in a well-designed system.
3459 Such an approach might result in email that was not authorized by the
3460 sending ADMD being unknowingly delivered to end users.
3462 Either general approach can be used, as they both leave a clear
3463 disposition of emails; either they are delivered in some manner or
3464 the sender is notified of the failure. Other dispositions such as
3465 "dropping" or deleting email after acceptance are inappropriate
3466 because they leave uncertainty and reduce the overall reliability and
3467 utility of email across the Internet.
3474Kitterman Standards Track [Page 62]
3476RFC 7208 Sender Policy Framework (SPF) April 2014
3479G.3. Policy for SPF Permerror
3481 The "permerror" result (see Section 2.6.7) indicates that the SPF
3482 processing module at the receiver determined that the retrieved SPF
3483 policy record could not be interpreted. This gives no true
3484 indication about the authorized use of the data found in the
3487 As with all results, implementers have a choice to make regarding
3488 what to do with a message that yields this result. SMTP allows only
3489 a few basic options.
3491 Rejection of the message is an option, in that it is the one thing a
3492 receiver can do to draw attention to the difficulty encountered while
3493 protecting itself from messages that do not have a definite SPF
3494 result of some kind. However, if the SPF implementation is defective
3495 and returns spurious "permerror" results, only the sender is actively
3496 notified of the defect (in the form of rejected mail), and not the
3497 receiver making use of SPF.
3499 The less intrusive handling choice is to deliver the message, perhaps
3500 with some kind of annotation of the difficulty encountered and/or
3501 logging of a similar nature. However, this will not be desirable to
3502 SPF verifier operators that wish to implement SPF checking as
3503 strictly as possible, nor is this sort of passive reporting of
3504 problems typically effective.
3506 There is of course the option of placing this choice in the hands of
3507 the SPF verifier operator rather than the implementer since this kind
3508 of choice is often a matter of local policy rather than a condition
3509 with a universal solution, but this adds one more piece of complexity
3510 to an already non-trivial environment.
3512 Both implementers and SPF verifier operators need to be cautious of
3513 all choices and outcomes when handling SPF results.
3515G.4. Policy for SPF Temperror
3517 The "temperror" result (see Section 2.6.6) indicates that the SPF
3518 processing module at the receiver could not retrieve an SPF policy
3519 record due to a (probably) transient condition. This gives no true
3520 indication about the authorized use of the data found in the
3523 As with all results, implementers have a choice to make regarding
3524 what to do with a message that yields this result. SMTP allows only
3525 a few basic options.
3530Kitterman Standards Track [Page 63]
3532RFC 7208 Sender Policy Framework (SPF) April 2014
3535 Deferring the message is an option, in that it is the one thing a
3536 receiver can do to draw attention to the difficulty encountered while
3537 protecting itself from messages that do not have a definite SPF
3538 result of some kind. However, if the SPF implementation is defective
3539 and returns spurious "temperror" results, only the sender is actively
3540 notified of the defect (in the form of mail rejected after it times
3541 out of the sending queue), and not the receiver making use of SPF.
3543 Because of long queue lifetimes, it is possible that mail will be
3544 repeatedly deferred for several days, and so any awareness that the
3545 sender may have regarding a problem could be quite delayed. If
3546 "temperrors" persist for multiple delivery attempts, it might be
3547 preferable to treat the error as permanent and reduce the amount of
3548 time the message is in transit.
3550 The less intrusive handling choice is to deliver the message, perhaps
3551 with some kind of annotation of the difficulty encountered and/or
3552 logging of a similar nature. However, this will not be desirable to
3553 SPF verifier operators that wish to implement SPF checking as
3554 strictly as possible, nor is this sort of passive reporting of
3555 problems typically effective.
3557 There is of course the option of placing this choice in the hands of
3558 the SPF verifier operator rather than the implementer since this kind
3559 of choice is often a matter of local policy rather than a condition
3560 with a universal solution, but this adds one more piece of complexity
3561 to an already non-trivial environment.
3563 Both implementers and SPF verifier operators need to be cautious of
3564 all choices and outcomes when handling SPF results.
3569 Kitterman Technical Services
3571 Ellicott City, MD 21042
3572 United States of America
3574 EMail: scott@kitterman.com
3586Kitterman Standards Track [Page 64]