E-MailRelay

gverifierstatus.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2021 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
28 namespace 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 by the user of the verifier to give
42/// more context in the log 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///
51 class GSmtp::VerifierStatus
52{
53 public:
54 G_EXCEPTION( InvalidStatus , "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 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 public:
77 bool is_valid{false} ;
78 bool is_local{false} ;
79 bool temporary{false} ;
80 bool abort{false} ;
81 std::string recipient ; // verifier input, even if not valid
82 std::string full_name ; // description iff local
83 std::string address ; // mailbox if local, output address if remote
84 std::string response ;
85 std::string reason ;
86
87 private:
88 VerifierStatus() ;
89} ;
90
91#endif
GSmtp::VerifierStatus
A structure returned by GSmtp::Verifier to describe the status of a 'rcpt-to' or 'vrfy' recipient.
Definition: gverifierstatus.h:52
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 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
GSmtp
SMTP and message-store classes.
Definition: gadminserver.h:39