msg_auth_status/spf.rs
1//! Method spf Result
2
3/// Parsed SPF Result
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct SpfResult<'hdr> {
6 /// Result
7 pub code: SpfResultCode,
8 /// Reason if supplied
9 pub reason: Option<&'hdr str>,
10 /// smtp.mailfrom
11 pub smtp_mailfrom: Option<&'hdr str>,
12 /// smtp.helo
13 pub smtp_helo: Option<&'hdr str>,
14 /// Unparsed raw
15 pub raw: Option<&'hdr str>,
16}
17
18impl<'hdr> SpfResult<'hdr> {
19 pub(crate) fn set_smtp(&mut self, prop: &ptypes::SpfSmtp<'hdr>) -> bool {
20 match prop {
21 ptypes::SpfSmtp::MailFrom(val) => self.smtp_mailfrom = Some(val),
22 ptypes::SpfSmtp::Helo(val) => self.smtp_helo = Some(val),
23 }
24 true
25 }
26}
27
28/// SPF Result Codes - s.2.7.2
29/// SPF defined in RFC 7208 s.2.6 - Results evaluation
30#[derive(Clone, Debug, Default, PartialEq)]
31pub enum SpfResultCode {
32 /// Result code not seen
33 #[default]
34 Unknown,
35 /// Either (a) syntactically valid DNS domain name was extracted from the
36 /// SMTP session that could be used as the one to be authorized, or (b) no
37 /// SPF records were retrieved from the DNS.
38 NoneSpf,
39 /// An explicit statement that the client is authorized to inject mail with
40 /// the given identity.
41 Pass,
42 /// An explicit statement that the client is not authorized to use the domain
43 /// in the given identity.
44 Fail,
45 /// A weak statement by the publishing ADMD that the host is probably not
46 /// authorized. It has not published a stronger, more definitive policy that
47 /// results in a "fail".
48 SoftFail,
49 /// RFC 8601 - Section 2.4
50 /// Indication that some local policy mechanism was applied that augments or
51 /// even replaces (i.e., overrides) the result returned by the authentication
52 /// mechanism. The property and value in this case identify the local policy
53 /// that was applied and the result it returned.
54 Policy,
55 /// The ADMD has explicitly stated that it is not asserting whether the IP
56 /// address is authorized.
57 Neutral,
58 /// The SPF verifier encountered a transient (generally DNS) error while
59 /// performing the check. A later retry may succeed without further DNS
60 /// operator action.
61 TempError,
62 /// The domain's published records could not be correctly interpreted.
63 /// This signals an error condition that definitely requires DNS operator
64 /// intervention to be resolved.
65 PermError,
66}
67
68pub mod ptypes;
69pub use ptypes::SpfProperty;