E-MailRelay
genvelope.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2024 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file genvelope.h
19///
20
21#ifndef G_STORE_ENVELOPE_H
22#define G_STORE_ENVELOPE_H
23
24#include "gdef.h"
25#include "gmessagestore.h"
26#include "gstringarray.h"
27#include "gstringview.h"
28#include "gexception.h"
29#include <iostream>
30
31namespace GStore
32{
33 class Envelope ;
34}
35
36//| \class GStore::Envelope
37/// A structure containing the contents of an envelope file, with
38/// support for file reading, writing and copying.
39///
41{
42public:
43 G_EXCEPTION( ReadError , tx("cannot read envelope file") )
44 G_EXCEPTION( WriteError , tx("cannot write envelope file") )
45
46 static void read( std::istream & , Envelope & ) ;
47 ///< Reads an envelope from a stream. Throws on error.
48 ///< Input lines can be newline delimited, in which case
49 ///< 'crlf' is set false.
50
51 static std::size_t write( std::ostream & , const Envelope & ) ;
52 ///< Writes an envelope to a seekable stream. Returns the new
53 ///< endpos value. Returns zero and sets the fail state on
54 ///< error, if for example the stream is unseekable. Output
55 ///< lines are CR-LF delimited. The structure 'crlf' and
56 ///< 'endpos' fields should normally be updated after
57 ///< using write().
58
59 static void copyExtra( std::istream & , std::ostream & ) ;
60 ///< A convenience function to copy extra envelope lines from an
61 ///< envelope input stream to an output stream. Input lines
62 ///< can be newline delimited, but output is always CR-LF.
63 ///< Throws on input error; output errors are not checked.
64
65 static MessageStore::BodyType parseSmtpBodyType( const std::string & ,
66 MessageStore::BodyType default_ = MessageStore::BodyType::Unknown ) ;
67 ///< Parses an SMTP MAIL-FROM BODY= parameter. Returns
68 ///< the given default value if the string is empty.
69
70 static std::string smtpBodyType( MessageStore::BodyType ) ;
71 ///< Converts a body type enum into the corresponding
72 ///< SMTP keyword.
73
74public:
75 bool crlf {true} ;
76 bool utf8_mailboxes {false} ; // message requires next-hop server to support SMTPUTF8 (RFC-6531)
77 MessageStore::BodyType body_type {MessageStore::BodyType::Unknown} ;
78 std::string from ;
79 G::StringArray to_local ;
80 G::StringArray to_remote ;
81 std::string authentication ;
82 std::string client_socket_address ;
83 std::string client_certificate ;
84 std::string from_auth_in ;
85 std::string from_auth_out ;
86 std::string forward_to ;
87 std::string forward_to_address ;
88 std::string client_account_selector ;
89 std::size_t endpos {0U} ;
90} ;
91
92#endif
A structure containing the contents of an envelope file, with support for file reading,...
Definition: genvelope.h:41
static void copyExtra(std::istream &, std::ostream &)
A convenience function to copy extra envelope lines from an envelope input stream to an output stream...
Definition: genvelope.cpp:99
static std::size_t write(std::ostream &, const Envelope &)
Writes an envelope to a seekable stream.
Definition: genvelope.cpp:59
static std::string smtpBodyType(MessageStore::BodyType)
Converts a body type enum into the corresponding SMTP keyword.
Definition: genvelope.cpp:182
static void read(std::istream &, Envelope &)
Reads an envelope from a stream.
Definition: genvelope.cpp:113
static MessageStore::BodyType parseSmtpBodyType(const std::string &, MessageStore::BodyType default_=MessageStore::BodyType::Unknown)
Parses an SMTP MAIL-FROM BODY= parameter.
Definition: genvelope.cpp:175
Message store classes.
Definition: genvelope.cpp:30
std::vector< std::string > StringArray
A std::vector of std::strings.
Definition: gstringarray.h:30
constexpr const char * tx(const char *p) noexcept
A briefer alternative to G::gettext_noop().
Definition: ggettext.h:84