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::report::{AuthFailureType, Feedback, FeedbackType, IdentityAlignment};
|
12 |
|
13 | fn main() {
|
14 | // Generate ARF feedback
|
15 | let feedback = Feedback::new(FeedbackType::AuthFailure)
|
16 | .with_arrival_date(5934759438)
|
17 | .with_authentication_results("dkim=pass")
|
18 | .with_incidents(10)
|
19 | .with_original_envelope_id("821-abc-123")
|
20 | .with_original_mail_from("hello@world.org")
|
21 | .with_original_rcpt_to("ciao@mundo.org")
|
22 | .with_reported_domain("example.org")
|
23 | .with_reported_domain("example2.org")
|
24 | .with_reported_uri("uri:domain.org")
|
25 | .with_reported_uri("uri:domain2.org")
|
26 | .with_reporting_mta("Manchegator 2.0")
|
27 | .with_source_ip("192.168.1.1".parse().unwrap())
|
28 | .with_user_agent("DMARC-Meister")
|
29 | .with_version(2)
|
30 | .with_source_port(1234)
|
31 | .with_auth_failure(AuthFailureType::Dmarc)
|
32 | .with_dkim_adsp_dns("v=dkim1")
|
33 | .with_dkim_canonicalized_body("base64 goes here")
|
34 | .with_dkim_canonicalized_header("more base64")
|
35 | .with_dkim_domain("dkim-domain.org")
|
36 | .with_dkim_identity("my-dkim-identity@domain.org")
|
37 | .with_dkim_selector("the-selector")
|
38 | .with_dkim_selector_dns("v=dkim1;")
|
39 | .with_spf_dns("v=spf1")
|
40 | .with_identity_alignment(IdentityAlignment::DkimSpf)
|
41 | .with_message(&b"From: hello@world.org\r\nTo: ciao@mundo.org\r\n\r\n"[..])
|
42 | .to_rfc5322(
|
43 | ("DMARC Reports", "no-reply@example.org"),
|
44 | "ruf@otherdomain.com",
|
45 | "DMARC Authentication Failure Report",
|
46 | )
|
47 | .unwrap();
|
48 |
|
49 | // Print ARF feedback to stdout
|
50 | println!("{}", feedback);
|
51 | }
|