E-MailRelay
gverifierstatus.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2023 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 gverifierstatus.h
19///
20
21#ifndef G_SMTP_VERIFIER_STATUS_H
22#define G_SMTP_VERIFIER_STATUS_H
23
24#include "gdef.h"
25#include "gexception.h"
26#include <string>
27
28namespace GSmtp
29{
30 class VerifierStatus ;
31}
32
33//| \class GSmtp::VerifierStatus
34/// A structure returned by GSmtp::Verifier to describe the status of
35/// a 'rcpt-to' or 'vrfy' recipient.
36///
37/// If describing an invalid recipient then 'is_valid' is set false
38/// and a 'response' is supplied. The response is typically reported back
39/// to the submitter, so it should not contain too much detail.
40///
41/// The 'reason' string can be added to give more context in the log
42/// in addition to 'response'.
43///
44/// If a valid local recipient then 'is_local' is set true, 'full_name'
45/// is set to the full description of the mailbox and 'address' is set
46/// to the recipient's mailbox name (which should not have an at sign).
47///
48/// If a valid remote recipient then 'is_local' is set false, 'full_name'
49/// is empty, and 'address' is typically a copy of the original recipient.
50///
52{
53public:
54 G_EXCEPTION( InvalidStatus , tx("invalid verifier status") ) ;
55
56 static VerifierStatus invalid( const std::string & recipient ,
57 bool temporary = false ,
58 const std::string & response = {} ,
59 const std::string & reason = {} ) ;
60 ///< Factory function for an invalid address.
61
62 static VerifierStatus remote( const std::string & recipient ,
63 const std::string & address = {} ) ;
64 ///< Constructor for a valid remote mailbox.
65
66 static VerifierStatus local( const std::string & recipient ,
67 const std::string & full_name , const std::string & mbox ) ;
68 ///< Constructor for a valid local mailbox.
69
70 static VerifierStatus parse( const std::string & str ) ;
71 ///< Parses a str() string into a structure.
72
73 std::string str() const ;
74 ///< Returns a string representation of the structure.
75
76 bool utf8address() const ;
77 ///< Returns true if 'address' is utf8 according to
78 ///< GSmtp::ServerParser::mailboxStyle().
79
80public:
81 bool is_valid {false} ;
82 bool is_local {false} ;
83 bool temporary {false} ;
84 bool abort {false} ;
85 std::string recipient ; // verifier input, even if not valid
86 std::string full_name ; // description iff local
87 std::string address ; // mailbox if local, output address if remote
88 std::string response ;
89 std::string reason ;
90
91private:
93} ;
94
95#endif
A structure returned by GSmtp::Verifier to describe the status of a 'rcpt-to' or 'vrfy' recipient.
static VerifierStatus local(const std::string &recipient, const std::string &full_name, const std::string &mbox)
Constructor for a valid local mailbox.
std::string str() const
Returns a string representation of the structure.
bool utf8address() const
Returns true if 'address' is utf8 according to GSmtp::ServerParser::mailboxStyle().
static VerifierStatus parse(const std::string &str)
Parses a str() string into a structure.
static VerifierStatus invalid(const std::string &recipient, bool temporary=false, const std::string &response={}, const std::string &reason={})
Factory function for an invalid address.
static VerifierStatus remote(const std::string &recipient, const std::string &address={})
Constructor for a valid remote mailbox.
SMTP classes.
Definition: gadminserver.h:42
constexpr const char * tx(const char *p)
A briefer alternative to G::gettext_noop().
Definition: ggettext.h:84