forked from stalwartlabs/mail-auth
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspf_verify.rs
38 lines (34 loc) · 1.06 KB
/
spf_verify.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* Copyright (c) 2020-2023, Stalwart Labs Ltd.
*
* Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
* https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
* <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
* option. This file may not be copied, modified, or distributed
* except according to those terms.
*/
use mail_auth::{Resolver, SpfResult};
#[tokio::main]
async fn main() {
// Create a resolver using Cloudflare DNS
let resolver = Resolver::new_cloudflare_tls().unwrap();
// Verify HELO identity
let result = resolver
.verify_spf_helo(
"127.0.0.1".parse().unwrap(),
"gmail.com",
"my-host-domain.org",
)
.await;
assert_eq!(result.result(), SpfResult::Fail);
// Verify MAIL-FROM identity
let result = resolver
.verify_spf_sender(
"::1".parse().unwrap(),
"gmail.com",
"my-host-domain.org",
)
.await;
assert_eq!(result.result(), SpfResult::Fail);
}