E-MailRelay
gverifier.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 gverifier.h
19///
20
21#ifndef G_SMTP_VERIFIER_H
22#define G_SMTP_VERIFIER_H
23
24#include "gdef.h"
25#include "gverifierstatus.h"
26#include "gbasicaddress.h"
27#include "gslot.h"
28#include "gexception.h"
29#include <string>
30
31namespace GSmtp
32{
33 class Verifier ;
34}
35
36//| \class GSmtp::Verifier
37/// An asynchronous interface that verifies recipient 'to' addresses.
38/// This is used in the VRFY and RCPT commands in the smtp server
39/// protocol.
40/// \see GSmtp::ServerProtocol
41///
43{
44public:
45 enum class Command { VRFY , RCPT } ;
46 struct Info /// Extra information passed to GSmtp::Verifier::verify().
47 {
48 std::string mail_from_parameter ; // if RCPT, not VRFY
49 G::BasicAddress client_ip ;
50 std::string domain ;
51 std::string auth_mechanism ;
52 std::string auth_extra ;
53 } ;
54 struct Config /// Configuration passed to address verifier constructors.
55 {
56 unsigned int timeout {60U} ;
57 std::string domain ;
58 Config & set_timeout( unsigned int ) noexcept ;
59 Config & set_domain( const std::string & ) ;
60 } ;
61
62 virtual void verify( Command , const std::string & rcpt_to_parameter ,
63 const Info & ) = 0 ;
64 ///< Checks a recipient address and asynchronously returns a
65 ///< structure to indicate whether the address is a local
66 ///< mailbox, what the full name is, and the canonical address.
67
69 ///< Returns a signal that is emit()ed when the verify() request
70 ///< is complete.
71
72 virtual void cancel() = 0 ;
73 ///< Aborts any current processing.
74
75 virtual ~Verifier() = default ;
76 ///< Destructor.
77} ;
78
79inline GSmtp::Verifier::Config & GSmtp::Verifier::Config::set_timeout( unsigned int n ) noexcept { timeout = n ; return *this ; }
80inline GSmtp::Verifier::Config & GSmtp::Verifier::Config::set_domain( const std::string & s ) { domain = s ; return *this ; }
81
82#endif
An asynchronous interface that verifies recipient 'to' addresses.
Definition: gverifier.h:43
virtual ~Verifier()=default
Destructor.
virtual G::Slot::Signal< Command, const VerifierStatus & > & doneSignal()=0
Returns a signal that is emit()ed when the verify() request is complete.
virtual void cancel()=0
Aborts any current processing.
virtual void verify(Command, const std::string &rcpt_to_parameter, const Info &)=0
Checks a recipient address and asynchronously returns a structure to indicate whether the address is ...
A structure that holds a network address as a string with no dependency on any low-level network libr...
Definition: gbasicaddress.h:37
SMTP classes.
Definition: gadminserver.h:42
Configuration passed to address verifier constructors.
Definition: gverifier.h:55
Extra information passed to GSmtp::Verifier::verify().
Definition: gverifier.h:47
A slot holder, with connect() and emit() methods.
Definition: gslot.h:184