E-MailRelay

Classes | Public Member Functions | List of all members
GSmtp::Client Class Reference

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>`

Inheritance diagram for GSmtp::Client:

## Classes
struct | Config
| A structure containing GSmtp::Client configuration parameters. More...

## Public Member Functions
| Client (GNet::ExceptionSink, FilterFactory &, const GNet::Location &remote, const GAuth::SaslClientSecrets &client_secrets, const Config &config)
| Constructor. More...
| ~Client () override
| Destructor. More...
void | sendMessagesFrom (MessageStore &store)
| Sends all messages from the given message store once connected. More...
void | sendMessage (std::unique_ptr< StoredMessage > message)
| Starts sending the given message. More...
G::Slot::Signal< const std::string & > & | messageDoneSignal ()
| Returns a signal that indicates that sendMessage() has completed or failed. More...
| Client (const Client &)=delete
| Client (Client &&)=delete
void | operator= (const Client &)=delete
void | operator= (Client &&)=delete
Public Member Functions inherited from GNet::Client
| Client (ExceptionSink, const Location &remote_location, const Config &)
| Constructor. More...
void | connect ()
| Initiates a connection to the remote server. More...
bool | connected () const
| Returns true if connected to the peer. More...
bool | hasConnected () const
| Returns true if ever connected(). More...
void | disconnect ()
| Aborts the connection and destroys the object's internal state, resulting in a zombie object. More...
std::pair< bool, Address > | localAddress () const override
| Override from Connection. More...
std::pair< bool, Address > | peerAddress () const override
| Override from Connection. More...
std::string | connectionState () const override
| Returns the connection state display string. More...
std::string | peerCertificate () const override
| Returns the peer's TLS certificate. More...
Location | remoteLocation () const
| Returns a Location structure, including the result of name lookup if available. More...
bool | send (const std::string &data, std::size_t offset=0)
| Sends data to the peer and starts the response timer (if configured). More...
bool | send (const std::vector< G::string_view > &data, std::size_t offset=0)
| Overload for scatter/gather segments. More...
G::Slot::Signal< const std::string &, const std::string &, const std::string & > & | eventSignal () noexcept
| Returns a signal that indicates that something interesting has happened. More...
void | doOnDelete (const std::string &reason, bool done)
| Called by ClientPtr (or equivalent) to call onDelete(), just before this client object is deleted. More...
bool | finished () const
| Returns true if finish()ed or disconnect()ed. More...
LineBufferState | lineBuffer () const
| Returns information about the state of the internal line-buffer. More...
| ~Client () override
| Destructor. More...
| Client (const Client &)=delete
| Client (Client &&)=delete
void | operator= (const Client &)=delete
void | operator= (Client &&)=delete
Public Member Functions inherited from GNet::Connection
virtual | ~Connection ()=default
| Destructor.
virtual std::pair< bool, Address > | localAddress () const =0
| Returns the connection's local address. More...
virtual std::pair< bool, Address > | peerAddress () const =0
| Returns the connection's peer address. More...
virtual std::string | connectionState () const =0
| Returns the connection state as a display string. More...
virtual std::string | peerCertificate () const =0
| Returns the peer's TLS certificate. More...
Public Member Functions inherited from GNet::ExceptionSource
virtual std::string | exceptionSourceId () const
| Returns an identifying string for logging purposes, or the empty string. More...
virtual | ~ExceptionSource ()
| Destructor. More...
| ExceptionSource (const ExceptionSource &)=delete
| ExceptionSource (ExceptionSource &&)=delete
void | operator= (const ExceptionSource &)=delete
void | operator= (ExceptionSource &&)=delete

## Additional Inherited Members
Protected Member Functions inherited from GNet::Client
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 | finish (bool with_socket_shutdown)
| Indicates that the last data has been sent and the client is expecting a peer disconnect. More...
void | clearInput ()
| Clears the input LineBuffer and cancels the response timer if running. More...
virtual bool | onReceive (const char *data, std::size_t size, std::size_t eolsize, std::size_t linesize, char c0)=0
| Called with received data. More...
virtual void | onConnect ()=0
| Called once connected.
virtual void | onSendComplete ()=0
| Called when all residual data from send() has been sent.
virtual void | onDelete (const std::string &reason)=0
| Called just before ClientPtr destroys the Client as the result of handling an exception. More...
void | secureConnect ()
| Starts TLS/SSL client-side negotiation. More...

## Detailed Description

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 53 of file gsmtpclient.h.

## Constructor & Destructor Documentation

## ◆ Client()

GSmtp::Client::Client | ( | GNet::ExceptionSink | es,
|  | FilterFactory & | ff,
|  | const GNet::Location & | remote,
|  | const GAuth::SaslClientSecrets & | client_secrets,
|  | const Config & | config
| ) |  |

Constructor.

Starts connecting immediately.

Use sendMessagesFrom() once, or use sendMessage() repeatedly. Wait for a messageDoneSignal() between each sendMessage().

Definition at line 34 of file gsmtpclient.cpp.

## ◆ ~Client()

GSmtp::Client::~Client | ( |  | ) |
| override

Destructor.

Definition at line 48 of file gsmtpclient.cpp.

## Member Function Documentation

## ◆ messageDoneSignal()

G::Slot::Signal< const std::string & > & GSmtp::Client::messageDoneSignal | ( |  | ) |

Returns a signal that indicates that sendMessage() has completed or failed.

Definition at line 67 of file gsmtpclient.cpp.

## ◆ sendMessage()

void GSmtp::Client::sendMessage | ( | std::unique_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 filtering 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.

Does nothing if there are no message recipients.

Definition at line 79 of file gsmtpclient.cpp.

## ◆ sendMessagesFrom()

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 throw GNet::Done. See GNet::ClientPtr.

The messageDoneSignal() is not used when sending messages using this method.

Definition at line 72 of file gsmtpclient.cpp.

The documentation for this class was generated from the following files:

- /usr/src/slapt-src-x86_64/network/emailrelay/emailrelay-2.3/src/gsmtp/gsmtpclient.h
- /usr/src/slapt-src-x86_64/network/emailrelay/emailrelay-2.3/src/gsmtp/gsmtpclient.cpp