A class which acts as an SMTP client, extracting messages from a message store and forwarding them to a remote SMTP server. More...
#include <gsmtpclient.h>
Classes | |
struct | Config |
A structure containing GSmtp::Client configuration parameters. More... | |
Public Member Functions | |
Client (const GNet::ResolverInfo &remote, const GAuth::Secrets &secrets, Config config) | |
Constructor. More... | |
void | sendMessagesFrom (MessageStore &store) |
Sends all messages from the given message store once connected. More... | |
void | sendMessage (std::auto_ptr< StoredMessage > message) |
Starts sending the given message. More... | |
G::Signal1< std::string > & | messageDoneSignal () |
Returns a signal that indicates that sendMessage() has completed or failed. More... | |
Public Member Functions inherited from GNet::Client | |
Client (const ResolverInfo &remote_info, unsigned int connection_timeout=0U, unsigned int response_timeout=0U, unsigned int secure_connection_timeout=0U, const std::string &eol=std::string("\n"), const Address &local_interface=Address(0U), bool privileged=false, bool sync_dns=synchronousDnsDefault()) | |
Constructor. More... | |
G::Signal2< std::string, bool > & | doneSignal () |
Returns a signal that indicates that client processing is complete. More... | |
G::Signal2< std::string, std::string > & | eventSignal () |
Returns a signal that indicates that something interesting has happened. More... | |
G::Signal0 & | connectedSignal () |
Returns a signal that incidcates that the client has successfully connected to the server. More... | |
G::Signal0 & | secureSignal () |
Returns a signal that incidcates that the security layer has been successfully established. More... | |
Public Member Functions inherited from GNet::HeapClient | |
HeapClient (const ResolverInfo &remote_info, const Address &local_interface=Address(0U), bool privileged=false, bool sync_dns=synchronousDnsDefault(), unsigned int secure_connection_timeout=0U) | |
Constructor. More... | |
void | doDelete (const std::string &reason) |
Calls onDelete() and then does a delayed "delete this". More... | |
virtual void | onException (std::exception &) |
Final override from GNet::EventHandler. More... | |
void | doDeleteForExit () |
A destructor method that may be called at program termination when the normal doDelete() mechanism has become unusable. More... | |
Public Member Functions inherited from GNet::SimpleClient | |
SimpleClient (const ResolverInfo &remote_info, const Address &local_address=Address(0U), bool privileged=false, bool sync_dns=synchronousDnsDefault(), unsigned int secure_connection_timeout=0U) | |
Constructor. More... | |
void | connect () |
Initates a connection to the remote server. More... | |
bool | connected () const |
Returns true if connected to the peer. More... | |
virtual std::pair< bool, Address > | localAddress () const |
Override from Connection. More... | |
virtual std::pair< bool, Address > | peerAddress () const |
Override from Connection. More... | |
virtual std::string | peerCertificate () const |
Returns the peer's TLS certificate. More... | |
ResolverInfo | resolverInfo () const |
Returns a ResolverInfo structure containing the result of host() and service() name lookup if available. More... | |
void | updateResolverInfo (const ResolverInfo &) |
Updates the constructor's ResolverInfo object with the given one as long as both objects have the same host and service name. More... | |
virtual void | readEvent () |
Final override from GNet::EventHandler. More... | |
virtual void | writeEvent () |
Final override from GNet::EventHandler. More... | |
bool | send (const std::string &data, std::string::size_type offset=0) |
Returns true if all sent, or false if flow control was asserted. More... | |
Public Member Functions inherited from GNet::EventHandler | |
virtual | ~EventHandler () |
Destructor. More... | |
virtual void | exceptionEvent () |
Called for an exception event. More... | |
Public Member Functions inherited from GNet::Connection | |
virtual | ~Connection () |
Destructor. More... | |
Public Member Functions inherited from GNet::SocketProtocolSink | |
virtual | ~SocketProtocolSink () |
Destructor. More... | |
Protected Member Functions | |
virtual | ~Client () |
Destructor. More... | |
virtual void | onConnect () |
Final override from GNet::SimpleClient. More... | |
virtual bool | onReceive (const std::string &) |
Final override from GNet::Client. More... | |
virtual void | onDelete (const std::string &, bool) |
Final override from GNet::HeapClient. More... | |
virtual void | onSendComplete () |
Final override from GNet::BufferedClient. More... | |
virtual void | onSecure (const std::string &) |
Final override from GNet::SocketProtocol. More... | |
Protected Member Functions inherited from GNet::Client | |
void | clearInput () |
Clears any pending input from the server. More... | |
virtual void | onDeleteImp (const std::string &, bool) |
Override from GNet::HeapClient. More... | |
virtual void | onConnectImp () |
Final override from GNet::SimpleClient. More... | |
virtual void | onData (const char *, SimpleClient::size_type) |
Final override from GNet::SocketProtocolSink. More... | |
virtual void | onConnecting () |
Final override from GNet::HeapClient. More... | |
virtual void | onSendImp () |
Final override from GNet::SimpleClient. More... | |
Protected Member Functions inherited from GNet::HeapClient | |
virtual | ~HeapClient () |
Destructor. More... | |
Protected Member Functions inherited from GNet::SimpleClient | |
virtual | ~SimpleClient () |
Destructor. More... | |
StreamSocket & | socket () |
Returns a reference to the socket. Throws if not connected. More... | |
const StreamSocket & | socket () const |
Returns a const reference to the socket. Throws if not connected. More... | |
void | sslConnect () |
Starts TLS/SSL client-side negotiation. More... | |
std::string | logId () const |
Returns a identification string for logging purposes. More... | |
Additional Inherited Members | |
Public Types inherited from GNet::SimpleClient | |
enum | ConnectStatus { Success, Failure, Retry, ImmediateSuccess } |
enum | State { Idle, Resolving, Connecting, Connected, Socksing } |
typedef std::string::size_type | size_type |
Static Public Member Functions inherited from GNet::SimpleClient | |
static bool | synchronousDnsDefault () |
Returns true if DNS queries should normally be synchronous on this platform. More... | |
Static Protected Member Functions inherited from GNet::SimpleClient | |
static bool | canRetry (const std::string &reason) |
Parses the given failure reason and returns true if the client can reasonably retry at some later time. More... | |
A class which acts as an SMTP client, extracting messages from a message store and forwarding them to a remote SMTP server.
Definition at line 55 of file gsmtpclient.h.
GSmtp::Client::Client | ( | const GNet::ResolverInfo & | remote, |
const GAuth::Secrets & | secrets, | ||
Config | config | ||
) |
Constructor.
Starts connecting immediately.
All Client instances must be on the heap since they delete themselves after raising the done signal.
Definition at line 42 of file gsmtpclient.cpp.
References G::Signal0::connect(), G::Signal2< P1, P2 >::connect(), GSmtp::ClientProtocol::doneSignal(), GSmtp::ClientProtocol::preprocessorSignal(), and G::slot().
|
protectedvirtual |
G::Signal1< std::string > & GSmtp::Client::messageDoneSignal | ( | ) |
Returns a signal that indicates that sendMessage() has completed or failed.
Definition at line 62 of file gsmtpclient.cpp.
|
protectedvirtual |
Final override from GNet::SimpleClient.
Implements GNet::SimpleClient.
Definition at line 152 of file gsmtpclient.cpp.
|
protectedvirtual |
Final override from GNet::HeapClient.
Implements GNet::HeapClient.
Definition at line 271 of file gsmtpclient.cpp.
|
protectedvirtual |
Final override from GNet::Client.
Implements GNet::Client.
Definition at line 264 of file gsmtpclient.cpp.
References G_DEBUG, and G::Str::printable().
|
protectedvirtual |
Final override from GNet::SocketProtocol.
Implements GNet::SocketProtocolSink.
Definition at line 121 of file gsmtpclient.cpp.
|
protectedvirtual |
Final override from GNet::BufferedClient.
Implements GNet::SimpleClient.
Definition at line 282 of file gsmtpclient.cpp.
void GSmtp::Client::sendMessage | ( | std::auto_ptr< StoredMessage > | message | ) |
Starts sending the given message.
Cannot be called if there is a message already in the pipeline.
The messageDoneSignal() is used to indicate that the message processing has finished or failed.
The message is fail()ed if it cannot be sent. If this Client object is deleted before the message is sent the message is neither fail()ed or destroy()ed.
Definition at line 74 of file gsmtpclient.cpp.
References G_ASSERT.
void GSmtp::Client::sendMessagesFrom | ( | MessageStore & | store | ) |
Sends all messages from the given message store once connected.
This must be used immediately after construction with a non-empty message store.
Once all messages have been sent the client will delete itself (see HeapClient).
The base class doneSignal() can be used as an indication that all messages have been sent and the object is about to delete itself.
Definition at line 67 of file gsmtpclient.cpp.
References GSmtp::MessageStore::empty(), and G_ASSERT.