1 #ifndef MESSAGE_DOT_HPP_INCLUDED
2 #define MESSAGE_DOT_HPP_INCLUDED
10 #include "Mailbox.hpp"
14 #include <glog/logging.h>
18 // RFC-5322 header names
19 auto constexpr ARC_Authentication_Results
= "ARC-Authentication-Results";
20 auto constexpr ARC_Message_Signature
= "ARC-Message-Signature";
21 auto constexpr ARC_Seal
= "ARC-Seal";
23 auto constexpr Authentication_Results
= "Authentication-Results";
24 auto constexpr DKIM_Signature
= "DKIM-Signature";
25 auto constexpr Delivered_To
= "Delivered-To";
26 auto constexpr From
= "From";
27 auto constexpr In_Reply_To
= "In-Reply-To";
28 auto constexpr Received_SPF
= "Received-SPF";
29 auto constexpr Reply_To
= "Reply-To";
30 auto constexpr Return_Path
= "Return-Path";
31 auto constexpr Subject
= "Subject";
34 auto constexpr Content_Type
= "Content-Type";
35 auto constexpr MIME_Version
= "MIME-Version";
38 header(std::string_view n
, std::string_view v
)
44 std::string
as_string() const;
46 std::string_view
as_view() const
48 // Verify that name and value views point to the same text.
49 CHECK_EQ(name
.begin() + name
.length() + 1, value
.begin());
51 static_cast<size_t>(std::distance(name
.begin(), value
.end()))};
54 bool operator==(std::string_view n
) const { return iequal(n
, name
); }
56 std::string_view name
;
57 std::string_view value
;
65 struct mailbox_name_addr_list
{
67 std::vector
<name_addr
> name_addr_list
;
71 bool parse(std::string_view input
);
72 bool parse_hdr(std::string_view input
);
74 std::string
as_string() const;
76 bool write(std::ostream
& out
) const;
78 std::vector
<header
> headers
;
80 std::string_view
get_header(std::string_view hdr
) const;
82 std::string_view field_name
;
83 std::string_view field_value
;
85 std::string_view body
;
87 // Parsing of the RFC-5322.From header
88 mailbox_name_addr_list from_parsed
;
89 std::string dmarc_from
;
90 std::string dmarc_from_domain
;
96 std::string reply_to_str
;
98 // New Authentication_Results field
101 // New DKIM-Signature that includes above AR
105 std::vector
<std::string
> arc_hdrs
;
108 bool authentication_results_parse(std::string_view input
,
109 std::string
& authservid
,
110 std::string
& ar_results
);
112 bool authentication(message::parsed
& msg
,
114 char const* selector
,
117 void dkim_check(message::parsed
& msg
, char const* domain
);
119 void remove_delivery_headers(message::parsed
& msg
);
121 void dkim_sign(message::parsed
& msg
,
123 char const* selector
,
126 void rewrite_from_to(message::parsed
& msg
,
127 std::string mail_from
,
128 std::string reply_to
,
130 char const* selector
,
133 void print_spf_envelope_froms(char const* domain
, message::parsed
& msg
);
135 } // namespace message
137 #endif // MESSAGE_DOT_HPP_INCLUDED