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::string maybe_name
;
68 std::vector
<name_addr
> name_addr_list
;
72 bool parse(std::string_view input
);
73 bool parse_hdr(std::string_view input
);
75 std::string
as_string() const;
77 bool write(std::ostream
& out
) const;
79 std::vector
<header
> headers
;
81 std::string_view
get_header(std::string_view hdr
) const;
83 std::string_view field_name
;
84 std::string_view field_value
;
86 std::string_view body
;
88 // Parsing of the RFC-5322.From header
89 mailbox_name_addr_list from_parsed
;
90 std::string dmarc_from
;
91 std::string dmarc_from_domain
;
97 std::string reply_to_str
;
99 // New Authentication_Results field
102 // New DKIM-Signature that includes above AR
106 std::vector
<std::string
> arc_hdrs
;
109 bool mailbox_list_parse(std::string_view input
,
110 mailbox_name_addr_list
& name_addr_list
);
112 bool authentication_results_parse(std::string_view input
,
113 std::string
& authservid
,
114 std::string
& ar_results
);
116 bool authentication(message::parsed
& msg
,
118 char const* selector
,
121 void dkim_check(message::parsed
& msg
, char const* domain
);
123 void remove_delivery_headers(message::parsed
& msg
);
125 void dkim_sign(message::parsed
& msg
,
127 char const* selector
,
130 void rewrite_from_to(message::parsed
& msg
,
131 std::string mail_from
,
132 std::string reply_to
,
134 char const* selector
,
137 void print_spf_envelope_froms(char const* domain
, message::parsed
& msg
);
139 } // namespace message
141 #endif // MESSAGE_DOT_HPP_INCLUDED