Skip to main content

Sender Policy Framework (SPF) for Authorizing Use of Domains in Email, Version 1
RFC 7208

Document Type RFC - Proposed Standard (April 2014) Errata IPR
Obsoletes RFC 4408
Author Scott Kitterman
Last updated 2020-01-21
RFC stream Internet Engineering Task Force (IETF)
Formats
Additional resources Mailing list discussion
IESG Responsible AD Pete Resnick
Send notices to (None)
RFC 7208
lt;sender> is strong-bad@email.example.com.  The IPv4 SMTP client
   IP is 192.0.2.3.  The IPv6 SMTP client IP is 2001:db8::cb01.  The PTR
   domain name of the client IP is mx.example.org.

Kitterman                    Standards Track                   [Page 32]
RFC 7208              Sender Policy Framework (SPF)           April 2014

   macro                       expansion
   -------  ----------------------------
   %{s}     strong-bad@email.example.com
   %{o}                email.example.com
   %{d}                email.example.com
   %{d4}               email.example.com
   %{d3}               email.example.com
   %{d2}                     example.com
   %{d1}                             com
   %{dr}               com.example.email
   %{d2r}                  example.email
   %{l}                       strong-bad
   %{l-}                      strong.bad
   %{lr}                      strong-bad
   %{lr-}                     bad.strong
   %{l1r-}                        strong

   macro-string                                               expansion
   --------------------------------------------------------------------
   %{ir}.%{v}._spf.%{d2}             3.2.0.192.in-addr._spf.example.com
   %{lr-}.lp._spf.%{d2}                  bad.strong.lp._spf.example.com

   %{lr-}.lp.%{ir}.%{v}._spf.%{d2}
                       bad.strong.lp.3.2.0.192.in-addr._spf.example.com

   %{ir}.%{v}.%{l1r-}.lp._spf.%{d2}
                           3.2.0.192.in-addr.strong.lp._spf.example.com

   %{d2}.trusted-domains.example.net
                                example.com.trusted-domains.example.net

   IPv6:
   %{ir}.%{v}._spf.%{d2}                               1.0.b.c.0.0.0.0.
   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

8.  Result Handling

   This section provides guidance for SPF verifier operators in response
   to the various possible outputs of check_host() on a message.
   Definitions of SPF results are presented in Section 2.6; this section
   provides more detail on each for use in developing local policy for
   message handling.

   Every operating environment is different.  There are some receivers
   for whom strict adherence to SPF is appropriate, and definitive
   treatment of messages that are evaluated to be explicitly
   unauthorized ("fail" and sometimes "softfail") is the norm.  There
   are others for which the "false negative" cases are more of a

Kitterman                    Standards Track                   [Page 33]
RFC 7208              Sender Policy Framework (SPF)           April 2014

   concern.  This concern is typically handled by merely recording the
   result in the header and allowing the message to pass on for
   additional processing.  There are still others where SPF is one of
   several inputs to the message-handling decision.  As such, there is
   no comprehensive normative requirement for message handling in
   response to any particular result.  This section is provided to
   present a complete picture of the likely cause of each result and,
   where available, the experience gained during experimental
   deployment.

   There are essentially two classes of handling choices:

   o  Handling within the SMTP session that attempted to deliver the
      message, such as by returning a permanent SMTP error (rejection)
      or temporary SMTP error ("try again later");

   o  Permitting the message to pass (a successful SMTP reply code) and
      adding an additional header field that indicates the result
      returned by check_host() and other salient details; this is
      discussed in more detail in Section 9.

8.1.  None

   With a "none" result, the SPF verifier has no information at all
   about the authorization or lack thereof of the client to use the
   checked identity or identities.  The check_host() function completed
   without errors but was not able to reach any conclusion.

8.2.  Neutral

   A "neutral" result indicates that although a policy for the identity
   was discovered, there is no definite assertion (positive or negative)
   about the client.

   A "neutral" result MUST be treated exactly like the "none" result;
   the distinction exists only for informational purposes.  Treating
   "neutral" more harshly than "none" would discourage ADMDs from
   testing the use of SPF records (see Section 10.1).

8.3.  Pass

   A "pass" result means the client is authorized to inject mail with
   the given identity.  The domain can now, in the sense of reputation,
   be considered responsible for sending the message.  Further policy
   checks can now proceed with confidence in the legitimate use of the
   identity.  This is further discussed in Appendix G.1.

Kitterman                    Standards Track                   [Page 34]
RFC 7208              Sender Policy Framework (SPF)           April 2014

8.4.  Fail

   A "fail" result is an explicit statement that the client is not
   authorized to use the domain in the given identity.  Disposition of
   SPF fail messages is a matter of local policy.  See Appendix G.2 for
   considerations on developing local policy.

   If the checking software chooses to reject the mail during the SMTP
   transaction, then it SHOULD use an SMTP reply code of 550 (see
   [RFC5321]) and, if supported, the 5.7.1 enhanced status code (see
   [RFC3463], Section 3.8), in addition to an appropriate reply text.
   The check_host() function will return either a default explanation
   string or one from the domain that published the SPF records (see
   Section 6.2).  If the information does not originate with the
   checking software, it is good to make it clear that the text is
   provided by the sender's domain.  For example:

       550 5.7.1 SPF MAIL FROM check failed:
       550 5.7.1 The domain example.com explains:
       550 5.7.1 Please see http://www.example.com/mailpolicy.html

   If the checking software chooses not to reject the mail during the
   SMTP transaction, then it SHOULD add a Received-SPF or
   Authentication-Results header field (see Section 9) to communicate
   this result to downstream message processors.  While this is true for
   all SPF results, it is of particular importance for "fail" results
   since the message is explicitly not authorized by the ADMD.

8.5.  Softfail

   A "softfail" result ought to be treated as somewhere between "fail"
   and "neutral"/"none".  The ADMD believes the host is not authorized
   but is not willing to make a strong policy statement.  Receiving
   software SHOULD NOT reject the message based solely on this result,
   but MAY subject the message to closer scrutiny than normal.

   The ADMD wants to discourage the use of this host and thus desires
   limited feedback when a "softfail" result occurs.  For example, the
   recipient's MUA could highlight the "softfail" status, or the
   receiving MTA could give the sender a message using greylisting
   [RFC6647], with a note the first time the message is received, but
   accept it on a later attempt based on receiver policy.

Kitterman                    Standards Track                   [Page 35]
RFC 7208              Sender Policy Framework (SPF)           April 2014

8.6.  Temperror

   A "temperror" result means the SPF verifier encountered a transient
   (generally DNS) error while performing the check.  Checking software
   can choose to accept or temporarily reject the message.  If the
   message is rejected during the SMTP transaction for this reason, the
   software SHOULD use an SMTP reply code of 451 and, if supported, the
   4.4.3 enhanced status code (see Section 3.5 of [RFC3463]).  These
   errors can be caused by problems in either the sender's or receiver's
   DNS software.  See Appendix G.4 for considerations on developing
   local policy.

8.7.  Permerror

   A "permerror" result means the domain's published records could not
   be correctly interpreted.  This signals an error condition that
   definitely requires DNS operator intervention to be resolved.  If the
   message is rejected during the SMTP transaction for this reason, the
   software SHOULD use an SMTP reply code of 550 and, if supported, the
   5.5.2 enhanced status code (see [RFC3463], Section 3.6).  Be aware
   that if the ADMD uses macros (Section 7), it is possible that this
   result is due to the checked identities having an unexpected format.
   It is also possible that this result is generated by certain SPF
   verifiers due to the input arguments having an unexpected format; see
   Section 4.8.  See Appendix G.3 for considerations on developing local
   policy.

9.  Recording the Result

   To provide downstream agents, such as MUAs, with the information they
   might need in terms of evaluating or representing the apparent safety
   of the message content, it is RECOMMENDED that SMTP receivers record
   the result of SPF processing in the message header.  For SPF verifier
   operators that choose to record SPF results in the header of the
   message for processing by internal filters or MUAs, two methods are
   presented: Section 9.1 defines the Received-SPF field, which is the
   results field originally defined for SPF use.  Section 9.2 discusses
   the Authentication-Results header field [RFC7001], which was
   specified more recently and is designed for use by SPF and other
   authentication methods.

   Both are in common use, and hence both are included here.  However,
   it is important to note that they were designed to serve slightly
   different purposes.  Received-SPF is intended to include enough
   information to enable reconstruction of the SPF evaluation of the
   message, while Authentication-Results is designed only to relay the
   result itself and related output details of likely use to end users
   (e.g., what property of the message was actually authenticated and

Kitterman                    Standards Track                   [Page 36]
RFC 7208              Sender Policy Framework (SPF)           April 2014

   what it contained), leaving reconstructive work to the purview of
   system logs and the Received field contents.  Also, Received-SPF
   relies on compliance of agents within the receiving ADMD to adhere to
   the header field ordering rules of [RFC5321] and [RFC5322], while
   Authentication-Results includes some provisions to protect against
   non-compliant implementations.

   An SPF verifier operator could choose to use both to serve different
   downstream agents.  In such cases, care needs to be taken to ensure
   that both fields are conveying the same details, or unexpected
   results can occur.

9.1.  The Received-SPF Header Field

   The Received-SPF header field is a trace field (see [RFC5322],
   Section 3.6.7) and SHOULD be prepended to the existing header, above
   the Received: field that is generated by the SMTP receiver.  It MUST
   appear above all other Received-SPF fields in the message.  The
   header field has the following format:

   header-field     = "Received-SPF:" [CFWS] result FWS [comment FWS]
                      [ key-value-list ] CRLF

   result           = "pass" / "fail" / "softfail" / "neutral" /
                      "none" / "temperror" / "permerror"

   key-value-list   = key-value-pair *( ";" [CFWS] key-value-pair )
                      [";"]

   key-value-pair   = key [CFWS] "=" ( dot-atom / quoted-string )

   key              = "client-ip" / "envelope-from" / "helo" /
                      "problem" / "receiver" / "identity" /
                       "mechanism" / name

   identity         = "mailfrom"   ; for the "MAIL FROM" identity
                      / "helo"     ; for the "HELO" identity
                      / name       ; other identities

   dot-atom         = <unquoted word as per [RFC5322]>
   quoted-string    = <quoted string as per [RFC5322]>
   comment          = <comment string as per [RFC5322]>
   CFWS             = <comment or folding white space as per [RFC5322]>
   FWS              = <folding white space as per [RFC5322]>
   CRLF             = <standard end-of-line token as per [RFC5322]>

Kitterman                    Standards Track                   [Page 37]
RFC 7208              Sender Policy Framework (SPF)           April 2014

   The header field SHOULD include a "(...)" style comment after the
   result, conveying supporting information for the result, such as
   <ip>, <sender>, and <domain>.

   The following key-value pairs are designed for later machine parsing.
   SPF verifiers SHOULD give enough information so that the SPF results
   can be verified -- that is, at least "client-ip", "helo", and, if the
   "MAIL FROM" identity was checked, "envelope-from".

   client-ip      the IP address of the SMTP client

   envelope-from  the envelope sender mailbox

   helo           the host name given in the HELO or EHLO command

   mechanism      the mechanism that matched (if no mechanisms matched,
                  substitute the word "default")

   problem        if an error was returned, details about the error

   receiver       the host name of the SPF verifier

   identity       the identity that was checked; see the <identity>
                  ABNF rule

   Other keys MAY be defined by SPF verifiers.

   SPF verifiers MUST make sure that the Received-SPF header field does
   not contain invalid characters, is not excessively long (see
   [RFC5322], Section 2.1.1), and does not contain malicious data that
   has been provided by the sender.

   Examples of various header field styles that could be generated are
   the following:

   Received-SPF: pass (mybox.example.org: domain of
    myname@example.com designates 192.0.2.1 as permitted sender)
       receiver=mybox.example.org; client-ip=192.0.2.1;
       envelope-from="myname@example.com"; helo=foo.example.com;

   Received-SPF: fail (mybox.example.org: domain of
                     myname@example.com does not designate
                     192.0.2.1 as permitted sender)
                     identity=mailfrom; client-ip=192.0.2.1;
                     envelope-from="myname@example.com";

Kitterman                    Standards Track                   [Page 38]
RFC 7208              Sender Policy Framework (SPF)           April 2014

   Received-SPF: pass (mybox.example.org: domain of
    myname@example.com designates 192.0.2.1 as permitted sender)
       receiver=mybox.example.org; client-ip=192.0.2.1;
       mechanism=ip4:192.0.2.1; envelope-from="myname@example.com";
       helo=foo.example.com;

9.2.  SPF Results in the Authentication-Results Header Field

   As mentioned in Section 9, the Authentication-Results header field is
   designed to communicate lists of tests a border MTA did and their
   results.  The specified elements of the field provide less
   information than the Received-SPF field:

   Authentication-Results: myhost.example.org; spf=pass
     smtp.mailfrom=example.net

   Received-SPF: pass (myhost.example.org: domain of
    myname@example.com designates 192.0.2.1 as permitted sender)
       receiver=mybox.example.org; client-ip=192.0.2.1;
       envelope-from="myname@example.com"; helo=foo.example.com;

   It is, however, possible to add CFWS in the "reason" part of an
   Authentication-Results header field and provide the equivalent
   information, if desired.

   As an example, an expanded Authentication-Results header field might
   look like (for a "MAIL FROM" check in this example):

   Authentication-Results: myhost.example.org; spf=pass
     reason="client-ip=192.0.2.1; smtp.helo=foo.example.com"
     smtp.mailfrom=user@example.net

10.  Effects on Infrastructure

   This section outlines the major implications that adoption of this
   protocol will have on various entities involved in Internet email.
   It is intended to make clear to the reader where this protocol
   knowingly affects the operation of such entities.  This section is
   not a "how-to" manual, or a "best practices" document, and it is not
   a comprehensive list of what such entities ought to do in light of
   this specification.

   This section provides operational advice and instruction only.  It is
   non-normative.

   [RFC5598] describes the Internet email architecture.  This section is
   organized based on the different segments of the architecture.

Kitterman                    Standards Track                   [Page 39]
RFC 7208              Sender Policy Framework (SPF)           April 2014

10.1.  Sending Domains

   Originating ADMDs (ADministrative Management Domains --
   Sections 2.2.1 and 2.3 of [RFC5598]) that wish to be compliant with
   this specification will need to determine the list of relays
   ([RFC5598], Section 2.2.2) that they allow to use their domain name
   in the "HELO" and "MAIL FROM" identities when relaying to other
   ADMDs.  It is recognized that forming such a list is not just a
   simple technical exercise, but involves policy decisions with both
   technical and administrative considerations.

10.1.1.  DNS Resource Considerations

   Minimizing the DNS resources needed for SPF lookups can be done by
   choosing directives that require less DNS information and by placing
   lower-cost mechanisms earlier in the SPF record.

   Section 4.6.4 specifies the limits receivers have to use.  It is
   essential to publish records that do not exceed these requirements.
   It is also required to carefully weigh the cost and the
   maintainability of licit solutions.

   For example, consider a domain set up as follows:

      example.com.     IN MX   10 mx.example.com.
                       IN MX   20 mx2.example.com.
      mx.example.com.  IN A    192.0.2.1
      mx2.example.com. IN A    192.0.2.129

   Assume the administrative point is to authorize (pass) mx and mx2
   while failing every other host.  Compare the following solutions:

   Best record:
      example.com.   IN TXT  "v=spf1 ip4:192.0.2.1 ip4:192.0.2.129 -all"

   Good record:
      $ORIGIN example.com.
      @              IN TXT  "v=spf1 a:authorized-spf.example.com -all"
      authorized-spf IN A    192.0.2.1
                     IN A    192.0.2.129

   Expensive record:
      example.com.   IN TXT  "v=spf1 mx:example.com -all"

   Wasteful, bad record:
      example.com.   IN TXT  "v=spf1 ip4:192.0.2.0/24 mx -all"

Kitterman                    Standards Track                   [Page 40]
RFC 7208              Sender Policy Framework (SPF)           April 2014

10.1.2.  Administrator's Considerations

   There might be administrative considerations: using "a" over "ip4" or
   "ip6" allows hosts to be renumbered easily at the cost of a DNS query
   per receiver.  Using "mx" over "a" allows the set of mail hosts to be
   changed easily.  Unless such changes are common, it is better to use
   the less resource-intensive mechanisms like "ip4" and "ip6" over "a"
   or "a" over "mx".

   In some specific cases, standard advice on record content is
   appropriate.  Publishing SPF records for domains that send no mail is
   a well-established best practice.  The record for a domain that sends
   no mail is:

      www.example.com.   IN TXT  "v=spf1 -all"

   Publishing SPF records for individual hosts is also best practice.
   The host name is generally the identity used in the 5321.HELO/.EHLO
   command.  In the case of messages with a null 5321.MailFrom, this is
   used as the domain for 5321.MailFrom SPF checks, in addition to being
   used in 5321.HELO/.EHLO-based SPF checks.  The standard SPF record
   for an individual host that is involved in mail processing is:

      relay.example.com.   IN TXT  "v=spf1 a -all"

   Validating correct deployment is difficult.  [RFC6652] describes one
   mechanism for soliciting feedback on SPF failures.  Another
   suggestion can be found in Appendix C.

   Regardless of the method used, understanding the ADMD's outbound mail
   architecture is essential to effective deployment.

10.1.3.  Bounces

   As explained in Section 2.4, [RFC5321] allows the MAIL FROM to be
   null, which is typical of some Delivery Status Notifications
   [RFC3464], commonly called email bounces.  In this case, the only
   entity available for performing an SPF check is the "HELO" identity
   defined in Section 1.1.4.  SPF functionality is enhanced by
   administrators ensuring this identity is set correctly and has an
   appropriate SPF record.  It is normal to have the "HELO" identity set
   to the host name instead of the domain.  Zone file generation for
   significant numbers of hosts can be consolidated using the "redirect"
   modifier and scripted for initial deployment.  Specific deployment
   advice is given above in Section 10.1.2.

Kitterman                    Standards Track                   [Page 41]
RFC 7208              Sender Policy Framework (SPF)           April 2014

10.2.  Receivers

   SPF results can be used in combination with other methods to
   determine the final local disposition (either positive or negative)
   of a message.  It can also be considered dispositive on its own.

   An attempt to have one organization (sender) direct the email-
   handling policies of another (receiver) is inherently challenging and
   often controversial.  As stated elsewhere in this document, there is
   no comprehensive normative requirement for specific handling of a
   message based on SPF results.  The information presented in Section 8
   and in Appendix G is offered for receiver consideration when forming
   local handling policies.

   The primary considerations are that SPF might return "pass" for mail
   that is ultimately harmful (e.g., spammers that arrange for SPF to
   pass using disposable domain names, or virus or spam outbreaks from
   within trusted sources), and might also return "fail" for mail that
   is ultimately legitimate (e.g., legitimate mail that has traversed a
   mail alias).  It is important to take both of these cases under
   consideration when establishing local handling policy.

10.3.  Mediators

   Mediators are a type of User Actor [RFC5598].  That is, a mediator
   takes 'delivery' of a message and posts a 'submission' of a new
   message.  The mediator can make the newly posted message be as
   similar to or as different from the original message as they wish.
   Examples include mailing lists (see Section 5.3 of [RFC5598]) and
   ReSenders (Section 5.2 of [RFC5598]).  This is discussed in
   [RFC5321], Section 3.9.  For the operation of SPF, the essential
   concern is the email address in the 5321.MailFrom command for the new
   message.

   Because SPF evaluation is based on the IP address of the "last"
   sending SMTP server, the address of the mediator will be used, rather
   than the address of the SMTP server that sent the message to the
   mediator.  Some mediators retain the email address from the original
   message, while some use a new address.

   If the address is the same as for the original message, and the
   original message had an associated SPF record, then the SPF
   evaluation will fail unless mitigations such as those described in
   Appendix D are used.

Kitterman                    Standards Track                   [Page 42]
RFC 7208              Sender Policy Framework (SPF)           April 2014

11.  Security Considerations

11.1.  Processing Limits

   As with most aspects of email, there are a number of ways that
   malicious parties could use the protocol as an avenue for a DoS
   attack.  The processing limits outlined in Section 4.6.4 are designed
   to prevent attacks such as the following:

   o  A malicious party could create an SPF record with many references
      to a victim's domain and send many emails to different SPF
      verifiers; those SPF verifiers would then create a DoS attack.  In
      effect, the SPF verifiers are being used to amplify the attacker's
      bandwidth by using fewer octets in the SMTP session than are used
      by the DNS queries.  Using SPF verifiers also allows the attacker
      to hide the true source of the attack.  This potential attack is
      based on large volumes of mail being transmitted.

   o  Whereas implementations of check_host() are supposed to limit the
      number of DNS lookups, malicious domains could publish records
      that exceed these limits in an attempt to waste computation effort
      at their targets when they send them mail.  Malicious domains
      could also design SPF records that cause particular
      implementations to use excessive memory or CPU or to trigger bugs.
      If a receiver is configured to accept mail with an SPF result of
      "temperror", such an attack might result in mail that would
      otherwise have been rejected due to an SPF "fail" result being
      accepted.  This potential attack is based on specially crafted SPF
      records being used to exhaust DNS resources of the victim.

   o  Malicious parties could send a large volume of mail purporting to
      come from the intended target to a wide variety of legitimate mail
      hosts.  These legitimate machines would then present a DNS load on
      the target as they fetched the relevant records.

   o  Malicious parties could, in theory, use SPF records as a vehicle
      for DNS lookup amplification for a DoS attack.  In this scenario,
      the attacker publishes an SPF record in its own DNS that uses "a"
      and "mx" mechanisms directed toward the intended victim, e.g.,
      "a:example.com a:foo.example.com a:bar.example.com ..." and then
      distributes mail with a MAIL FROM value including its own domain
      in large volume to a wide variety of destinations.  Any such
      destination operating an SPF verifier will begin querying all of
      the names associated with the "a" mechanisms in that record.  The
      names used in the record needn't exist for the attack to be
      effective.  Operational experience since the publication of
      [RFC4408] suggests that mitigation of this class of attack can be
      accomplished with minimal impact on the deployed base by having

Kitterman                    Standards Track                   [Page 43]
RFC 7208              Sender Policy Framework (SPF)           April 2014

      the verifier abort processing and return "permerror"
      (Section 2.6.7) as soon as more than two "void lookups" have been
      encountered (defined in Section 4.6.4).

   Of these, the case of a third party referenced in the SPF record is
   the easiest for a DoS attack to effectively exploit.  As a result,
   limits that might seem reasonable for an individual mail server can
   still allow an unreasonable amount of bandwidth amplification.
   Therefore, the processing limits need to be quite low.

11.2.  SPF-Authorized Email May Contain Other False Identities

   The "MAIL FROM" and "HELO" identity authorizations do not provide
   assurance about the authorization/authenticity of other identities
   used in the message.  It is entirely possible for a malicious sender
   to inject a message using his own domain in the identities used by
   SPF and have that domain's SPF record authorize the sending host, and
   yet the message can easily list other identities in its header.
   Unless the user or the MUA takes care to note that the authorized
   identity does not match the other more commonly presented identities
   (such as the From: header field), the user might be lulled into a
   false sense of security.

11.3.  Spoofed DNS and IP Data

   There are two aspects of this protocol that malicious parties could
   exploit to undermine the validity of the check_host() function:

   o  The evaluation of check_host() relies heavily on DNS.  A malicious
      attacker could attack the DNS infrastructure and cause
      check_host() to see spoofed DNS data, and then return incorrect
      results.  This could include returning "pass" for an <ip> value
      where the actual domain's record would evaluate to "fail".  See
      [RFC3833] for a description of DNS weaknesses, and see [RFC4033]
      for a countermeasure.

   o  The client IP address, <ip>, is assumed to be correct.  In a
      modern, correctly configured system, the risk of this not being
      true is nil.

11.4.  Cross-User Forgery

   By definition, SPF policies just map domain names to sets of
   authorized MTAs, not whole email addresses to sets of authorized
   users.  Although the "l" macro (Section 7) provides a limited way to
   define individual sets of authorized MTAs for specific email
   addresses, it is generally impossible to verify, through SPF, the use
   of specific email addresses by individual users of the same MTA.

Kitterman                    Standards Track                   [Page 44]
RFC 7208              Sender Policy Framework (SPF)           April 2014

   It is up to mail services and their MTAs to directly prevent
   cross-user forgery: based on SMTP AUTH ([RFC4954]), users have to be
   restricted to using only those email addresses that are actually
   under their control (see Section 6.1 of [RFC6409]).  Another means to
   verify the identity of individual users is message cryptography, such
   as Pretty Good Privacy (PGP) ([RFC4880]) or S/MIME ([RFC5751]).

11.5.  Untrusted Information Sources

   An SPF-compliant receiver gathers information from the SMTP commands
   it receives and from the published DNS records of the sending domain
   holder (e.g., "HELO" domain name, the "MAIL FROM" address from the
   envelope, and SPF DNS records published by the domain holder).  These
   parameters are not validated in the SMTP process.

   All of these pieces of information are generated by actors outside of
   the authority of the receiver, and thus are not guaranteed to be
   accurate or legitimate.

11.5.1.  Recorded Results

   This information, passed to the receiver in the Received-SPF: or
   Authentication-Results: trace fields, can be returned to the client
   MTA as an SMTP rejection message.  If such an SMTP rejection message
   is generated, the information from the trace fields has to be checked
   for such problems as invalid characters and excessively long lines.

11.5.2.  External Explanations

   When the authorization check fails, an explanation string could be
   included in the reject response.  Both the sender and the rejecting
   receiver need to be aware that the explanation was determined by the
   publisher of the SPF record checked and, in general, not the
   receiver.  The explanation can contain malicious URLs, or it might be
   offensive or misleading.

   Explanations returned to sender domains due to "exp" modifiers
   (Section 6.2) were generated by the sender policy published by the
   domain holders themselves.  As long as messages are only returned
   with non-delivery notifications ([RFC3464]) to domains publishing the
   explanation strings from their own DNS SPF records, the only affected
   parties are the original publishers of the domain's SPF records.

   In practice, such non-delivery notifications can be misdirected, such
   as when an MTA accepts an email and only later generates the
   notification to a forged address, or when an email forwarder does not
   direct the bounce back to the original sender.

Kitterman                    Standards Track                   [Page 45]
RFC 7208              Sender Policy Framework (SPF)           April 2014

11.5.3.  Macro Expansion

   Macros (Section 7) allow senders to inject arbitrary text (any
   non-null [US-ASCII] character) into receiver DNS queries.  It is
   necessary to be prepared for hostile or unexpected content.

11.6.  Privacy Exposure

   Checking SPF records causes DNS queries to be sent to the domain
   owner.  These DNS queries, especially if they are caused by the
   "exists" mechanism, can contain information about who is sending
   email and likely to which MTA the email is being sent.  This can
   introduce some privacy concerns, which are more or less of an issue
   depending on local laws and the relationship between the ADMD and the
   person sending the email.

11.7.  Delivering Mail Producing a "Fail" Result

   Operators that choose to deliver mail for which SPF produces a "fail"
   result need to understand that they are admitting content that is
   explicitly not authorized by the purported sender.  While there are
   known failure modes that can be considered "false negatives", the
   distinct choice to admit those messages increases end-user exposure
   to likely harm.  This is especially true for domains belonging to
   known good actors that are typically well-behaved; unauthorized mail
   from those sources might well be subjected to much higher skepticism
   and content analysis.

   SPF does not, however, include the capacity to distinguish good
   actors from bad ones, nor does it handle the concept of known actors
   versus unknown ones.  Those notions are out of scope for this
   specification.

12.  Collected ABNF

   This section is normative, and any discrepancies with the ABNF
   fragments in the preceding text are to be resolved in favor of this
   grammar.

   See [RFC5234] for ABNF notation.  Please note that as per this ABNF
   definition, literal text strings (those in quotes) are case-
   insensitive.  Hence, "mx" matches "mx", "MX", "mX", and "Mx".

   record           = version terms *SP
   version          = "v=spf1"

   terms            = *( 1*SP ( directive / modifier ) )

Kitterman                    Standards Track                   [Page 46]
RFC 7208              Sender Policy Framework (SPF)           April 2014

   directive        = [ qualifier ] mechanism
   qualifier        = "+" / "-" / "?" / "~"
   mechanism        = ( all / include
                      / a / mx / ptr / ip4 / ip6 / exists )

   all              = "all"
   include          = "include"  ":" domain-spec
   a                = "a"      [ ":" domain-spec ] [ dual-cidr-length ]
   mx               = "mx"     [ ":" domain-spec ] [ dual-cidr-length ]
   ptr              = "ptr"    [ ":" domain-spec ]
   ip4              = "ip4"      ":" ip4-network   [ ip4-cidr-length ]
   ip6              = "ip6"      ":" ip6-network   [ ip6-cidr-length ]
   exists           = "exists"   ":" domain-spec

   modifier         = redirect / explanation / unknown-modifier
   redirect         = "redirect" "=" domain-spec
   explanation      = "exp" "=" domain-spec
   unknown-modifier = name "=" macro-string
                      ; where name is not any known modifier

   ip4-cidr-length  = "/" ("0" / %x31-39 0*1DIGIT) ; value range 0-32
   ip6-cidr-length  = "/" ("0" / %x31-39 0*2DIGIT) ; value range 0-128
   dual-cidr-length = [ ip4-cidr-length ] [ "/" ip6-cidr-length ]

   ip4-network      = qnum "." qnum "." qnum "." qnum
   qnum             = DIGIT                 ; 0-9
                      / %x31-39 DIGIT       ; 10-99
                      / "1" 2DIGIT          ; 100-199
                      / "2" %x30-34 DIGIT   ; 200-249
                      / "25" %x30-35        ; 250-255
            ; conventional dotted-quad notation, e.g., 192.0.2.0
   ip6-network      = <as per Section 2.2 of [RFC4291]>
            ; e.g., 2001:db8::cd30

   domain-spec      = macro-string domain-end
   domain-end       = ( "." toplabel [ "." ] ) / macro-expand

   toplabel         = ( *alphanum ALPHA *alphanum ) /
                      ( 1*alphanum "-" *( alphanum / "-" ) alphanum )
                      ; LDH rule plus additional TLD restrictions
                      ; (see Section 2 of [RFC3696] for background)
   alphanum         = ALPHA / DIGIT

   explain-string   = *( macro-string / SP )

   macro-string     = *( macro-expand / macro-literal )
   macro-expand     = ( "%{" macro-letter transformers *delimiter "}" )
                      / "%%" / "%_" / "%-"

Kitterman                    Standards Track                   [Page 47]
RFC 7208              Sender Policy Framework (SPF)           April 2014

   macro-literal    = %x21-24 / %x26-7E
                      ; visible characters except "%"
   macro-letter     = "s" / "l" / "o" / "d" / "i" / "p" / "h" /
                      "c" / "r" / "t" / "v"
   transformers     = *DIGIT [ "r" ]
   delimiter        = "." / "-" / "+" / "," / "/" / "_" / "="

   name             = ALPHA *( ALPHA / DIGIT / "-" / "_" / "." )

   header-field     = "Received-SPF:" [CFWS] result FWS [comment FWS]
                      [ key-value-list ] CRLF

   result           = "pass" / "fail" / "softfail" / "neutral" /
                      "none" / "temperror" / "permerror"

   key-value-list   = key-value-pair *( ";" [CFWS] key-value-pair )
                      [";"]

   key-value-pair   = key [CFWS] "=" ( dot-atom / quoted-string )

   key              = "client-ip" / "envelope-from" / "helo" /
                      "problem" / "receiver" / "identity" /
                       "mechanism" / name

   identity         = "mailfrom"   ; for the "MAIL FROM" identity
                      / "helo"     ; for the "HELO" identity
                      / name       ; other identities

   sender           = Mailbox
   ip               = ip4-network / ip6-network
   ALPHA            = <A-Z / a-z as per [RFC5234]>
   DIGIT            = <0-9 as per [RFC5234]>
   SP               = <space character as per [RFC5234]>
   dot-atom         = <unquoted word as per [RFC5322]>
   quoted-string    = <quoted string as per [RFC5322]>
   comment          = <comment string as per [RFC5322]>
   CFWS             = <comment or folding white space as per [RFC5322]>
   FWS              = <folding white space as per [RFC5322]>
   CRLF             = <standard end-of-line token as per [RFC5322]>

13.  Contributors and Acknowledgements

   This document is largely based on the work of Meng Weng Wong, Mark
   Lentczner, and Wayne Schlitt.  Although, as this section
   acknowledges, many people have contributed to this document, a very
   large portion of the writing and editing is due to Meng, Mark, and
   Wayne.

Kitterman                    Standards Track                   [Page 48]
RFC 7208              Sender Policy Framework (SPF)           April 2014

   This design owes a debt of parentage to [RMX] by Hadmut Danisch and
   to [DMP] by Gordon Fecyk.  The idea of using a DNS record to check
   the legitimacy of an email address traces its ancestry further back
   through messages on the namedroppers mailing list by Paul Vixie
   [Vixie] (based on suggestion by Jim Miller) and by David Green
   [Green].

   Philip Gladstone contributed the concept of macros to the
   specification, multiplying the expressiveness of the language and
   making per-user and per-IP lookups possible.

   The authors of both this document and [RFC4408] would also like to
   thank the literally hundreds of individuals who have participated in
   the development of this design.  They are far too numerous to name,
   but they include the following:

      The participants in the SPFbis working group.  The folks on the
      spf-discuss mailing list.  The folks on the SPAM-L mailing list.
      The folks on the IRTF ASRG mailing list.  The folks on the IETF
      MARID mailing list.  The folks on #perl.

14.  IANA Considerations

14.1.  The SPF DNS Record Type

   Per [RFC4408], the IANA assigned the Resource Record Type and Qtype
   from the "Domain Name System (DNS) Parameters" registry for the SPF
   RR type with code 99.  The format of this type is identical to the
   TXT RR [RFC1035].  The character content of the record is encoded as
   [US-ASCII].

   Studies have shown that RRTYPE 99 has not seen any substantial use,
   and in fact its existence and mechanism defined in [RFC4408] have led
   to some interoperability issues.  Accordingly, its use is no longer
   appropriate for SPF version 1; implementations are not to use it.

   IANA has updated the "Resource Record (RR) TYPEs" registry to
   indicate that this document is the reference document for that
   RRTYPE.

Kitterman                    Standards Track                   [Page 49]
RFC 7208              Sender Policy Framework (SPF)           April 2014

14.2.  The Received-SPF Mail Header Field

   Per [RFC3864], the "Received-SPF:" header field is added to the IANA
   "Permanent Message Header Field Names" registry.  The following is
   the registration template:

      Header field name: Received-SPF Applicable protocol: mail
      ([RFC5322]) Status: standard Author/Change controller: IETF
      Specification document(s): RFC 7208

14.3.  SPF Modifier Registry

   IANA has changed the reference for the "exp" and "redirect" modifiers
   in the "Modifier Names" registry, under Sender Policy Framework
   Parameters, from [RFC4408] to this document.  Their status is
   unchanged.

15.  References

15.1.  Normative References

   [RFC1035]  Mockapetris, P., "Domain names - implementation and
              specification", STD 13, RFC 1035, November 1987.

   [RFC1123]  Braden, R., "Requirements for Internet Hosts - Application
              and Support", STD 3, RFC 1123, October 1989.

   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119, March 1997.

   [RFC3463]  Vaudreuil, G., "Enhanced Mail System Status Codes",
              RFC 3463, January 2003.

   [RFC3864]  Klyne, G., Nottingham, M., and J. Mogul, "Registration
              Procedures for Message Header Fields", BCP 90, RFC 3864,
              September 2004.

   [RFC3986]  Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform
              Resource Identifier (URI): Generic Syntax", STD 66,
              RFC 3986, January 2005.

   [RFC4291]  Hinden, R. and S. Deering, "IP Version 6 Addressing
              Architecture", RFC 4291, February 2006.

   [RFC5234]  Crocker, D. and P. Overell, "Augmented BNF for Syntax
              Specifications: ABNF", STD 68, RFC 5234, January 2008.

Kitterman                    Standards Track                   [Page 50]
RFC 7208              Sender Policy Framework (SPF)           April 2014

   [RFC5321]  Klensin, J., "Simple Mail Transfer Protocol", RFC 5321,
              October 2008.

   [RFC5322]  Resnick, P., Ed., "Internet Message Format", RFC 5322,
              October 2008.

   [RFC5598]  Crocker, D., "Internet Mail Architecture", RFC 5598,
              July 2009.

   [RFC5890]  Klensin, J., "Internationalized Domain Names for
              Applications (IDNA): Definitions and Document Framework",
              RFC 5890, August 2010.

   [RFC7001]  Kucherawy, M., "Message Header Field for Indicating
              Message Authentication Status", RFC 7001, September 2013.

   [US-ASCII]
              American National Standards Institute (formerly United
              States of America Standards Institute), "USA Code for
              Information Interchange, X3.4", 1968.

              ANSI X3.4-1968 has been replaced by newer versions with
              slight modifications, but the 1968 version remains
              definitive for the Internet.

15.2.  Informative References

   [BATV]     Levine, J., Crocker, D., Silberman, S., and T. Finch,
              "Bounce Address Tag Validation (BATV)", Work in Progress,
              May 2008.

   [DMP]      Fecyk, G., "Designated Mailers Protocol", Work in
              Progress, May 2004.

   [Green]    Green, D., "Domain-Authorized SMTP Mail", June 2002,
              <http://www.mhonarc.org/archive/html/ietf-asrg/2003-03/
              msg01525.html>.

   [RFC1034]  Mockapetris, P., "Domain names - concepts and facilities",
              STD 13, RFC 1034, November 1987.

   [RFC1983]  Malkin, G., "Internet Users' Glossary", RFC 1983,
              August 1996.

   [RFC2308]  Andrews, M., "Negative Caching of DNS Queries (DNS
              NCACHE)", RFC 2308, March 1998.

Kitterman                    Standards Track                   [Page 51]
RFC 7208              Sender Policy Framework (SPF)           April 2014

   [RFC2671]  Vixie, P., "Extension Mechanisms for DNS (EDNS0)",
              RFC 2671, August 1999.

   [RFC2782]  Gulbrandsen, A., Vixie, P., and L. Esibov, "A DNS RR for
              specifying the location of services (DNS SRV)", RFC 2782,
              February 2000.

   [RFC3464]  Moore, K. and G. Vaudreuil, "An Extensible Message Format
              for Delivery Status Notifications", RFC 3464,
              January 2003.

   [RFC3696]  Klensin, J., "Application Techniques for Checking and
              Transformation of Names", RFC 3696, February 2004.

   [RFC3833]  Atkins, D. and R. Austein, "Threat Analysis of the Domain
              Name System (DNS)", RFC 3833, August 2004.

   [RFC3834]  Moore, K., "Recommendations for Automatic Responses to
              Electronic Mail", RFC 3834, August 2004.

   [RFC4033]  Arends, R., Austein, R., Larson, M., Massey, D., and S.
              Rose, "DNS Security Introduction and Requirements",
              RFC 4033, March 2005.

   [RFC4408]  Wong, M. and W. Schlitt, "Sender Policy Framework (SPF)
              for Authorizing Use of Domains in E-Mail, Version 1",
              RFC 4408, April 2006.

   [RFC4632]  Fuller, V. and T. Li, "Classless Inter-domain Routing
              (CIDR): The Internet Address Assignment and Aggregation
              Plan", BCP 122, RFC 4632, August 2006.

   [RFC4880]  Callas, J., Donnerhacke, L., Finney, H., Shaw, D., and R.
              Thayer, "OpenPGP Message Format", RFC 4880, November 2007.

   [RFC4954]  Siemborski, R. and A. Melnikov, "SMTP Service Extension
              for Authentication", RFC 4954, July 2007.

   [RFC5507]  IAB, Faltstrom, P., Austein, R., and P. Koch, "Design
              Choices When Expanding the DNS", RFC 5507, April 2009.

   [RFC5751]  Ramsdell, B. and S. Turner, "Secure/Multipurpose Internet
              Mail Extensions (S/MIME) Version 3.2 Message
              Specification", RFC 5751, January 2010.

   [RFC5782]  Levine, J., "DNS Blacklists and Whitelists", RFC 5782,
              February 2010.

Kitterman                    Standards Track                   [Page 52]
RFC 7208              Sender Policy Framework (SPF)           April 2014

   [RFC6409]  Gellens, R. and J. Klensin, "Message Submission for Mail",
              STD 72, RFC 6409, November 2011.

   [RFC6647]  Kucherawy, M. and D. Crocker, "Email Greylisting: An
              Applicability Statement for SMTP", RFC 6647, June 2012.

   [RFC6648]  Saint-Andre, P., Crocker, D., and M. Nottingham,
              "Deprecating the "X-" Prefix and Similar Constructs in
              Application Protocols", BCP 178, RFC 6648, June 2012.

   [RFC6652]  Kitterman, S., "Sender Policy Framework (SPF)
              Authentication Failure Reporting Using the Abuse Reporting
              Format", RFC 6652, June 2012.

   [RFC6686]  Kucherawy, M., "Resolution of the Sender Policy Framework
              (SPF) and Sender ID Experiments", RFC 6686, July 2012.

   [RFC6891]  Damas, J., Graff, M., and P. Vixie, "Extension Mechanisms
              for DNS (EDNS(0))", STD 75, RFC 6891, April 2013.

   [RMX]      Danisch, H., "The RMX DNS RR and method for lightweight
              SMTP sender authorization", Work in Progress, May 2004.

   [Vixie]    Vixie, P., "Repudiating MAIL FROM", 2002,
              <http://marc.info/?l=namedroppers&m=102298170127004&w=4>.

Kitterman                    Standards Track                   [Page 53]
RFC 7208              Sender Policy Framework (SPF)           April 2014

Appendix A.  Extended Examples

   These examples are based on the following DNS setup:

   ; A domain with two mail servers, two hosts, and two servers
   ; at the domain name
   $ORIGIN example.com.
   @           MX  10 mail-a
               MX  20 mail-b
               A   192.0.2.10
               A   192.0.2.11
   amy         A   192.0.2.65
   bob         A   192.0.2.66
   mail-a      A   192.0.2.129
   mail-b      A   192.0.2.130
   www         CNAME example.com.

   ; A related domain
   $ORIGIN example.org.
   @           MX  10 mail-c
   mail-c      A   192.0.2.140

   ; The reverse IP for those addresses
   $ORIGIN 2.0.192.in-addr.arpa.
   10          PTR example.com.
   11          PTR example.com.
   65          PTR amy.example.com.
   66          PTR bob.example.com.
   129         PTR mail-a.example.com.
   130         PTR mail-b.example.com.
   140         PTR mail-c.example.org.

   ; A rogue reverse IP domain that claims to be
   ; something it's not
   $ORIGIN 0.0.10.in-addr.arpa.
   4           PTR bob.example.com.

Kitterman                    Standards Track                   [Page 54]
RFC 7208              Sender Policy Framework (SPF)           April 2014

A.1.  Simple Examples

   These examples show various possible published records for
   example.com and which values of <ip> would cause check_host() to
   return "pass".  Note that <domain> is "example.com".

   v=spf1 +all

      -- any <ip> passes

   v=spf1 a -all

      -- hosts 192.0.2.10 and 192.0.2.11 pass

   v=spf1 a:example.org -all

      -- no sending hosts pass since example.org has no A records

   v=spf1 mx -all

      -- sending hosts 192.0.2.129 and 192.0.2.130 pass

   v=spf1 mx:example.org -all

      -- sending host 192.0.2.140 passes

   v=spf1 mx mx:example.org -all

      -- sending hosts 192.0.2.129, 192.0.2.130, and 192.0.2.140 pass

   v=spf1 mx/30 mx:example.org/30 -all

      -- any sending host in 192.0.2.128/30 or 192.0.2.140/30 passes

   v=spf1 ptr -all

      -- sending host 192.0.2.65 passes (reverse DNS is valid and is
         in example.com)

      -- sending host 192.0.2.140 fails (reverse DNS is valid, but not
         in example.com)

      -- sending host 10.0.0.4 fails (reverse IP is not valid)

Kitterman                    Standards Track                   [Page 55]
RFC 7208              Sender Policy Framework (SPF)           April 2014

   v=spf1 ip4:192.0.2.128/28 -all

      -- sending host 192.0.2.65 fails

      -- sending host 192.0.2.129 passes

A.2.  Multiple Domain Example

   These examples show the effect of related records:

      example.org: "v=spf1 include:example.com include:example.net -all"

   This record would be used if mail from example.org actually came
   through servers at example.com and example.net.  Example.org's
   designated servers are the union of example.com's and example.net's
   designated servers.

      la.example.org: "v=spf1 redirect=example.org"

      ny.example.org: "v=spf1 redirect=example.org"

      sf.example.org: "v=spf1 redirect=example.org"

   These records allow a set of domains that all use the same mail
   system to make use of that mail system's record.  In this way, only
   the mail system's record needs to be updated when the mail setup
   changes.  These domains' records never have to change.

A.3.  DNS Blacklist (DNSBL) Style Example

   Imagine that, in addition to the domain records listed above, there
   are these (see [RFC5782]):

   $ORIGIN _spf.example.com.
   mary.mobile-users                   A 127.0.0.2
   fred.mobile-users                   A 127.0.0.2
   15.15.168.192.joel.remote-users     A 127.0.0.2
   16.15.168.192.joel.remote-users     A 127.0.0.2

Kitterman                    Standards Track                   [Page 56]
RFC 7208              Sender Policy Framework (SPF)           April 2014

   The following records describe users at example.com who mail from
   arbitrary servers, or who mail from personal servers.

   example.com:

   v=spf1 mx
          include:mobile-users._spf.%{d}
          include:remote-users._spf.%{d}
          -all

   mobile-users._spf.example.com:

   v=spf1 exists:%{l1r+}.%{d}

   remote-users._spf.example.com:

   v=spf1 exists:%{ir}.%{l1r+}.%{d}

A.4.  Multiple Requirements Example

   Say that your sender policy requires both that the IP address is
   within a certain range and that the reverse DNS for the IP matches.
   This can be done several ways, including the following:

   example.com.           SPF  ( "v=spf1 "
                                 "-include:ip4._spf.%{d} "
                                 "-include:ptr._spf.%{d} "
                                 "+all" )
   ip4._spf.example.com.  SPF  "v=spf1 -ip4:192.0.2.0/24 +all"
   ptr._spf.example.com.  SPF  "v=spf1 -ptr +all"

   This example shows how the "-include" mechanism can be useful, how an
   SPF record that ends in "+all" can be very restrictive, and the use
   of De Morgan's Law.

Appendix B.  Changes in Implementation Requirements from RFC 4408

   The modifications to implementation requirements from [RFC4408] are
   all either (a) corrections to errors in [RFC4408] or (b) additional
   documentation based on consensus of operational experience acquired
   since the publication of [RFC4408].

   o  Use of DNS RR type SPF (99) has been removed from the protocol;
      see [RFC6686] for background.

   o  A new DNS-related processing limit based on "void lookups" has
      been added (Section 4.6.4).

Kitterman                    Standards Track                   [Page 57]
RFC 7208              Sender Policy Framework (SPF)           April 2014

   o  Use of the ptr mechanism and the %p macro has been strongly
      discouraged (Sections 5.5 and 7.2).  The ptr mechanism and the %p
      macro remain part of the protocol because they were found to be in
      use, but records ought to be updated to avoid them.

   o  Use of the "Authentication-Results" header field [RFC7001] as a
      possible alternative to use of the "Received-SPF" header field is
      discussed (Section 9.2).

   o  There have been a number of minor corrections to the ABNF to make
      it more clear and correct (Section 12).  SPF library implementers
      should give the revised ABNF a careful review to determine if
      implementation changes are needed.

   o  Use of X- fields in the ABNF has been removed; see [RFC6648] for
      background.

   o  Ambiguity about how to deal with invalid <domain-spec> after macro
      expansion has been documented.  Depending on one specific behavior
      has to be avoided (Section 4.8).

   o  General operational information has been updated and expanded
      based on eight years of post-[RFC4408] operations experience.  See
      Section 10 and Appendices D through G below.

   o  Security considerations have been reviewed and updated
      (Section 11).

Appendix C.  Further Testing Advice

   Another approach that can be helpful is to publish records that
   include a "tracking exists:" mechanism.  By looking at the name
   server logs, a rough list can then be generated.  For example:

      v=spf1 exists:_h.%{h}._l.%{l}._o.%{o}._i.%{i}._spf.%{d} ?all

   This associated macro expansion would cause the sending HELO domain,
   local-part of the sending email address, domain part of the sending
   email address, and the IP address from which the connection was
   received to be embedded in an SPF query and logged in the sender's
   DNS logs.

   This approach, which has been used since very early in the SPF
   project, allows senders to unilaterally collect data to evaluate the
   correctness of their SPF records.  Unlike newer feedback mechanisms,
   it does not require any special cooperation from SPF verifiers.  A
   similar example, one of the earliest SPF records published, can still
   be found as of this writing at altavista.net.

Kitterman                    Standards Track                   [Page 58]
RFC 7208              Sender Policy Framework (SPF)           April 2014

Appendix D.  SPF/Mediator Interactions

   There are three places that techniques can be used to ameliorate
   unintended SPF failures with mediators.

D.1.  Originating ADMDs

   The beginning, when email is first sent:

   o  "Neutral" results could be given for IP addresses that might be
      forwarders, instead of "fail" results based on a list of known
      reliable forwarders.  For example:

         "v=spf1 mx ?exists:%{ir}.whitelist.example.org -all"

      This would cause a lookup on a DNS White List (DNSWL) and cause a
      result of "fail" only for email not coming from either the
      domain's mx host(s) (SPF pass) or whitelisted sources (SPF
      neutral).  This, in effect, outsources an element of sender policy
      to the maintainer of the whitelist.

   o  The "MAIL FROM" identity could have additional information in the
      local-part that cryptographically identifies the mail as coming
      from an authorized source.  In this case, an SPF record such as
      the following could be used:

         "v=spf1 mx exists:%{l}._spf_verify.%{d} -all"

      Then, a specialized DNS server can be set up to serve the
      _spf_verify subdomain that validates the local-part.  Although
      this requires an extra DNS lookup, this happens only when the
      email would otherwise be rejected as not coming from a known good
      source.

      Note that due to the 63-character limit for domain labels, this
      approach only works reliably if the local-part signature scheme is
      guaranteed to either only produce local-parts with a maximum of
      63 characters or gracefully handle truncated local-parts.  The
      method used to secure the local-part is a local implementation
      issue; it need not be standard.  An example of one way to do it
      can be found in [BATV].

   o  Similarly, a specialized DNS server could be set up that will
      rate-limit the email coming from unexpected IP addresses.

         "v=spf1 mx exists:%{ir}._spf_rate.%{d} -all"

Kitterman                    Standards Track                   [Page 59]
RFC 7208              Sender Policy Framework (SPF)           April 2014

   o  SPF allows the creation of per-user policies for special cases.
      For example, the following SPF record and appropriate wildcard DNS
      records can be used:

         "v=spf1 mx redirect=%{l1r+}._at_.%{o}._spf.%{d}"

D.2.  Mediators

   The middle, when email is forwarded:

   o  Mediators can solve the problem by rewriting the "MAIL FROM" to be
      in their own domain.  This means mail rejected from the external
      mailbox will have to be forwarded back to the original sender by
      the forwarding service.  Various schemes to do this exist, though
      they vary widely in complexity and resource requirements on the
      part of the mediator.

   o  Several popular MTAs can be forced from "alias" semantics to
      "mailing list" semantics by configuring an additional alias with
      "owner-" prepended to the original alias name (e.g., an alias of
      "friends: george@example.com, fred@example.org" would need another
      alias of the form "owner-friends: localowner").

   o  Mediators could reject mail that would "fail" SPF if forwarded
      using an SMTP reply code of 551, User not local (see Section 3.4
      of [RFC5321]) to communicate the correct target address to resend
      the mail to.

D.3.  Receiving ADMDs

   The end, when email is received:

   o  If the owner of the external mailbox wishes to trust the mediator,
      he can direct the external mailbox's MTA to skip SPF tests when
      the client host belongs to the mediator.

   o  Tests against other identities, such as the "HELO" identity, can
      be used to override a failed test against the "MAIL FROM"
      identity.

   o  For larger domains, it might not be possible to have a complete or
      accurate list of forwarding services used by the owners of the
      domain's mailboxes.  In such cases, whitelists of generally
      recognized forwarding services could be employed.

Kitterman                    Standards Track                   [Page 60]
RFC 7208              Sender Policy Framework (SPF)           April 2014

Appendix E.  Mail Services

   MSPs (Mail Service Providers -- Section 2.3 of [RFC5598]) that offer
   mail services to third-party domains, such as the sending of bulk
   mail, might want to adjust their configurations in light of the
   authorization check described in this document.  If the domain part
   of the "MAIL FROM" identity used for such email uses one of the MSP's
   domains, then the provider needs only to ensure that its sending host
   is authorized by its own SPF record, if any.

   If the "MAIL FROM" identity does not use the MSP's domain, then extra
   care has to be taken.  The SPF record format has several options for
   the third-party domain to authorize the service provider's MTAs to
   send mail on its behalf.  For MSPs, such as ISPs, that have a wide
   variety of customers using the same MTA, steps are required to
   mitigate the risk of cross-customer forgery (see Section 11.4).

Appendix F.  MTA Relays

   Relays are described in [RFC5598], Section 2.2.2.  The authorization
   check generally precludes the use of arbitrary MTA relays between the
   sender and receiver of an email message.

   Within an organization, MTA relays can be effectively deployed.
   However, for the purposes of this document, such relays are
   effectively transparent.  The SPF authorization check is a check
   between border MTAs of different ADMDs.

   For mail senders, this means published SPF records have to authorize
   any MTAs that actually send across the Internet.  Usually, these are
   just the border MTAs as internal MTAs simply forward mail to these
   MTAs for relaying.

   The receiving ADMD will generally want to perform the authorization
   check at the boundary MTAs, including all secondary MXs.  Internal
   MTAs (including MTAs that might serve as both boundary MTAs and
   internal relays from secondary MXs when they are processing the
   relayed mail stream) then do not perform the authorization test.  To
   perform the authorization test other than at the boundary, the host
   that first transferred the message to the receiving ADMD has to be
   determined, which can be difficult to extract from the message header
   because (a) header fields can be forged or malformed, and (b) there's
   no standard way to encode that information such that it can be
   reliably extracted.  Testing other than at the boundary is likely to
   produce unreliable results.  This is described further in Appendix D
   of [RFC7001].

Kitterman                    Standards Track                   [Page 61]
RFC 7208              Sender Policy Framework (SPF)           April 2014

Appendix G.  Local Policy Considerations

   SPF results can be used in combination with other methods to
   determine the final local disposition (either positive or negative)
   of a message.  It can also be considered dispositive on its own.

G.1.  Policy for SPF Pass

   SPF "pass" results can be used in combination with "whitelists" of
   known "good" domains to bypass some or all additional pre-delivery
   email checks.  Exactly which checks and how to determine appropriate
   whitelist entries have to be based on local conditions and
   requirements.

G.2.  Policy for SPF Fail

   SPF "fail" results can be used to reject messages during the SMTP
   transaction based on either "MAIL FROM" or "HELO" identity results.
   This reduces resource requirements for various content-filtering
   methods and conserves bandwidth since rejection can be done before
   the SMTP content is transferred.  It also gives immediate feedback to
   the sender, who might then be able to resolve the issue.  Due to some
   of the issues described in this section (Appendix G), SPF-based
   rejection does present some risk of rejecting legitimate email when
   rejecting email based on "MAIL FROM" results.

   SPF "fail" results can alternately be used as one input into a larger
   set of evaluations that might, based on a combination of SPF "fail"
   results with other evaluation techniques, result in the email being
   marked negatively in some way (this might be via delivery to a
   special spam folder, modifying subject lines, or other locally
   determined means).  Developing the details of such an approach has to
   be based on local conditions and requirements.  Using SPF results in
   this way does not have the advantages of resource conservation and
   immediate feedback to the sender associated with SMTP rejection, but
   could produce fewer undesirable rejections in a well-designed system.
   Such an approach might result in email that was not authorized by the
   sending ADMD being unknowingly delivered to end users.

   Either general approach can be used, as they both leave a clear
   disposition of emails; either they are delivered in some manner or
   the sender is notified of the failure.  Other dispositions such as
   "dropping" or deleting email after acceptance are inappropriate
   because they leave uncertainty and reduce the overall reliability and
   utility of email across the Internet.

Kitterman                    Standards Track                   [Page 62]
RFC 7208              Sender Policy Framework (SPF)           April 2014

G.3.  Policy for SPF Permerror

   The "permerror" result (see Section 2.6.7) indicates that the SPF
   processing module at the receiver determined that the retrieved SPF
   policy record could not be interpreted.  This gives no true
   indication about the authorized use of the data found in the
   envelope.

   As with all results, implementers have a choice to make regarding
   what to do with a message that yields this result.  SMTP allows only
   a few basic options.

   Rejection of the message is an option, in that it is the one thing a
   receiver can do to draw attention to the difficulty encountered while
   protecting itself from messages that do not have a definite SPF
   result of some kind.  However, if the SPF implementation is defective
   and returns spurious "permerror" results, only the sender is actively
   notified of the defect (in the form of rejected mail), and not the
   receiver making use of SPF.

   The less intrusive handling choice is to deliver the message, perhaps
   with some kind of annotation of the difficulty encountered and/or
   logging of a similar nature.  However, this will not be desirable to
   SPF verifier operators that wish to implement SPF checking as
   strictly as possible, nor is this sort of passive reporting of
   problems typically effective.

   There is of course the option of placing this choice in the hands of
   the SPF verifier operator rather than the implementer since this kind
   of choice is often a matter of local policy rather than a condition
   with a universal solution, but this adds one more piece of complexity
   to an already non-trivial environment.

   Both implementers and SPF verifier operators need to be cautious of
   all choices and outcomes when handling SPF results.

G.4.  Policy for SPF Temperror

   The "temperror" result (see Section 2.6.6) indicates that the SPF
   processing module at the receiver could not retrieve an SPF policy
   record due to a (probably) transient condition.  This gives no true
   indication about the authorized use of the data found in the
   envelope.

   As with all results, implementers have a choice to make regarding
   what to do with a message that yields this result.  SMTP allows only
   a few basic options.

Kitterman                    Standards Track                   [Page 63]
RFC 7208              Sender Policy Framework (SPF)           April 2014

   Deferring the message is an option, in that it is the one thing a
   receiver can do to draw attention to the difficulty encountered while
   protecting itself from messages that do not have a definite SPF
   result of some kind.  However, if the SPF implementation is defective
   and returns spurious "temperror" results, only the sender is actively
   notified of the defect (in the form of mail rejected after it times
   out of the sending queue), and not the receiver making use of SPF.

   Because of long queue lifetimes, it is possible that mail will be
   repeatedly deferred for several days, and so any awareness that the
   sender may have regarding a problem could be quite delayed.  If
   "temperrors" persist for multiple delivery attempts, it might be
   preferable to treat the error as permanent and reduce the amount of
   time the message is in transit.

   The less intrusive handling choice is to deliver the message, perhaps
   with some kind of annotation of the difficulty encountered and/or
   logging of a similar nature.  However, this will not be desirable to
   SPF verifier operators that wish to implement SPF checking as
   strictly as possible, nor is this sort of passive reporting of
   problems typically effective.

   There is of course the option of placing this choice in the hands of
   the SPF verifier operator rather than the implementer since this kind
   of choice is often a matter of local policy rather than a condition
   with a universal solution, but this adds one more piece of complexity
   to an already non-trivial environment.

   Both implementers and SPF verifier operators need to be cautious of
   all choices and outcomes when handling SPF results.

Author's Address

   Scott Kitterman
   Kitterman Technical Services
   3611 Scheel Dr.
   Ellicott City, MD  21042
   United States of America

   EMail: scott@kitterman.com

Kitterman                    Standards Track                   [Page 64]