E-MailRelay

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