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