rustexamples/arc_verify.rs -rw-r--r-- 939 B
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
11use mail_auth::{AuthenticatedMessage, DkimResult, Resolver};
12
13const TEST_MESSAGE: &str = include_str!("../resources/arc/001.txt");
14
15#[tokio::main]
16async fn main() {
17 // Create a resolver using Cloudflare DNS
18 let resolver = Resolver::new_cloudflare_tls().unwrap();
19
20 // Parse message
21 let authenticated_message = AuthenticatedMessage::parse(TEST_MESSAGE.as_bytes()).unwrap();
22
23 // Validate ARC chain
24 let result = resolver.verify_arc(&authenticated_message).await;
25
26 // Make sure ARC passed verification
27 assert_eq!(result.result(), &DkimResult::Pass);
28}