join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::BasicSmtpClient< Protocol > Class Template Reference

basic SMTP client. More...

#include <smtpclient.hpp>

Inheritance diagram for join::BasicSmtpClient< Protocol >:

Public Types

using Endpoint = typename Protocol::Endpoint
 
using Stream = typename Protocol::Stream
 

Public Member Functions

 BasicSmtpClient (const char *host, uint16_t port=25)
 create the basic SMTP client instance.
 
 BasicSmtpClient (const std::string &host, uint16_t port=25)
 create the basic SMTP client instance.
 
 BasicSmtpClient (const BasicSmtpClient &other)=delete
 create the basic SMTP client instance by copy.
 
BasicSmtpClientoperator= (const BasicSmtpClient &other)=delete
 assign the basic SMTP client instance by copy.
 
 BasicSmtpClient (BasicSmtpClient &&other)
 create the basic SMTP client instance by move.
 
BasicSmtpClientoperator= (BasicSmtpClient &&other)
 assign the basic SMTP client instance by move.
 
virtual ~BasicSmtpClient ()=default
 destroy the basic SMTP client instance.
 
virtual std::string scheme () const
 get scheme.
 
const std::string & host () const
 get host.
 
uint16_t port () const
 get port.
 
std::string authority () const
 get authority.
 
std::string url () const
 get URL.
 
void credentials (const std::string &login, const std::string &password)
 set credentials.
 
int setCertificate (const std::string &cert, const std::string &key="")
 set the certificate and the private key.
 
int setCaPath (const std::string &caPath)
 set the location of the trusted CA certificates.
 
int setCaFile (const std::string &caFile)
 set the location of the trusted CA certificate file.
 
void setVerify (bool verify, int depth=-1)
 Enable/Disable the verification of the peer certificate.
 
int setCipher (const std::string &cipher)
 set the cipher list (TLSv1.2 and below).
 
int setCipher_1_3 (const std::string &cipher)
 set the cipher list (TLSv1.3).
 
int send (const MailMessage &mail)
 send mail message.
 

Protected Member Functions

virtual int connect (const Endpoint &endpoint)
 make a connection to the given endpoint.
 
void close ()
 close the connection.
 
int sendMessage (const std::string &message)
 send message.
 
std::string readReplies (std::vector< std::string > *replies=nullptr)
 read replies.
 
int greeting ()
 handle greeting.
 
int initialize (std::vector< std::string > &replies)
 client init.
 
int startTls ()
 start encryption.
 
int loginAuthenticate ()
 authenticate using LOGIN.
 
int plainAuthenticate ()
 authenticate using PLAIN.
 
int sendFrom (const MailMessage &message)
 send sender address.
 
int sendTo (const MailMessage &message)
 send recpient address.
 
int sendData (const MailMessage &message)
 send message.
 
int quit ()
 send quit.
 
std::string hostname () const
 get host name.
 

Protected Attributes

Stream _stream
 stream.
 
std::string _host
 SMTP host.
 
uint16_t _port
 SMTP port.
 
std::string _login
 SMTP login.
 
std::string _password
 SMTP password.
 

Detailed Description

template<class Protocol>
class join::BasicSmtpClient< Protocol >

basic SMTP client.

Member Typedef Documentation

◆ Endpoint

template<class Protocol >
using join::BasicSmtpClient< Protocol >::Endpoint = typename Protocol::Endpoint

◆ Stream

template<class Protocol >
using join::BasicSmtpClient< Protocol >::Stream = typename Protocol::Stream

Constructor & Destructor Documentation

◆ BasicSmtpClient() [1/4]

template<class Protocol >
join::BasicSmtpClient< Protocol >::BasicSmtpClient ( const char * host,
uint16_t port = 25 )
inline

create the basic SMTP client instance.

Parameters
hosthost.
portport (default: 25).

◆ BasicSmtpClient() [2/4]

template<class Protocol >
join::BasicSmtpClient< Protocol >::BasicSmtpClient ( const std::string & host,
uint16_t port = 25 )
inline

create the basic SMTP client instance.

Parameters
hosthost.
portport (default: 25).

◆ BasicSmtpClient() [3/4]

template<class Protocol >
join::BasicSmtpClient< Protocol >::BasicSmtpClient ( const BasicSmtpClient< Protocol > & other)
delete

create the basic SMTP client instance by copy.

Parameters
otherrequest to copy.

◆ BasicSmtpClient() [4/4]

template<class Protocol >
join::BasicSmtpClient< Protocol >::BasicSmtpClient ( BasicSmtpClient< Protocol > && other)
inline

create the basic SMTP client instance by move.

Parameters
otherrequest to move.

◆ ~BasicSmtpClient()

template<class Protocol >
virtual join::BasicSmtpClient< Protocol >::~BasicSmtpClient ( )
virtualdefault

destroy the basic SMTP client instance.

Member Function Documentation

◆ authority()

template<class Protocol >
std::string join::BasicSmtpClient< Protocol >::authority ( ) const
inline

get authority.

Returns
authority.

◆ close()

template<class Protocol >
void join::BasicSmtpClient< Protocol >::close ( )
inlineprotected

close the connection.

Returns
this on success, nullptr on failure.

◆ connect()

template<class Protocol >
virtual int join::BasicSmtpClient< Protocol >::connect ( const Endpoint & endpoint)
inlineprotectedvirtual

make a connection to the given endpoint.

Parameters
endpointendpoint to connect to.
Returns
0 on success, -1 on failure.

Reimplemented in join::BasicSmtpSecureClient< Protocol >.

◆ credentials()

template<class Protocol >
void join::BasicSmtpClient< Protocol >::credentials ( const std::string & login,
const std::string & password )
inline

set credentials.

Parameters
loginlogin.
passwordpassword.

◆ greeting()

template<class Protocol >
int join::BasicSmtpClient< Protocol >::greeting ( )
inlineprotected

handle greeting.

Returns
0 on success, -1 on failure.

◆ host()

template<class Protocol >
const std::string & join::BasicSmtpClient< Protocol >::host ( ) const
inline

get host.

Returns
host.

◆ hostname()

template<class Protocol >
std::string join::BasicSmtpClient< Protocol >::hostname ( ) const
inlineprotected

get host name.

Returns
host name.

◆ initialize()

template<class Protocol >
int join::BasicSmtpClient< Protocol >::initialize ( std::vector< std::string > & replies)
inlineprotected

client init.

Parameters
repliesserver replies.
Returns
0 on success, -1 on failure.

◆ loginAuthenticate()

template<class Protocol >
int join::BasicSmtpClient< Protocol >::loginAuthenticate ( )
inlineprotected

authenticate using LOGIN.

Returns
0 on success, -1 on failure.

◆ operator=() [1/2]

template<class Protocol >
BasicSmtpClient & join::BasicSmtpClient< Protocol >::operator= ( BasicSmtpClient< Protocol > && other)
inline

assign the basic SMTP client instance by move.

Parameters
otherrequest to move.
Returns
a reference of the current object.

◆ operator=() [2/2]

template<class Protocol >
BasicSmtpClient & join::BasicSmtpClient< Protocol >::operator= ( const BasicSmtpClient< Protocol > & other)
delete

assign the basic SMTP client instance by copy.

Parameters
otherrequest to copy.
Returns
a reference of the current object.

◆ plainAuthenticate()

template<class Protocol >
int join::BasicSmtpClient< Protocol >::plainAuthenticate ( )
inlineprotected

authenticate using PLAIN.

Returns
0 on success, -1 on failure.

◆ port()

template<class Protocol >
uint16_t join::BasicSmtpClient< Protocol >::port ( ) const
inline

get port.

Returns
port.

◆ quit()

template<class Protocol >
int join::BasicSmtpClient< Protocol >::quit ( )
inlineprotected

send quit.

Returns
0 on success, -1 on failure.

◆ readReplies()

template<class Protocol >
std::string join::BasicSmtpClient< Protocol >::readReplies ( std::vector< std::string > * replies = nullptr)
inlineprotected

read replies.

Parameters
repliesreplies to read.
Returns
reply code.

◆ scheme()

template<class Protocol >
virtual std::string join::BasicSmtpClient< Protocol >::scheme ( ) const
inlinevirtual

get scheme.

Returns
scheme.

Reimplemented in join::BasicSmtpSecureClient< Protocol >.

◆ send()

template<class Protocol >
int join::BasicSmtpClient< Protocol >::send ( const MailMessage & mail)
inline

send mail message.

Parameters
mailmail message to send.
Returns
0 on success, -1 on failure.

◆ sendData()

template<class Protocol >
int join::BasicSmtpClient< Protocol >::sendData ( const MailMessage & message)
inlineprotected

send message.

Parameters
messagemessage to send.
Returns
0 on success, -1 on failure.

◆ sendFrom()

template<class Protocol >
int join::BasicSmtpClient< Protocol >::sendFrom ( const MailMessage & message)
inlineprotected

send sender address.

Parameters
messagemail message.
Returns
0 on success, -1 on failure.

◆ sendMessage()

template<class Protocol >
int join::BasicSmtpClient< Protocol >::sendMessage ( const std::string & message)
inlineprotected

send message.

Parameters
messagemessage to send.
Returns
0 on success, -1 on failure.

◆ sendTo()

template<class Protocol >
int join::BasicSmtpClient< Protocol >::sendTo ( const MailMessage & message)
inlineprotected

send recpient address.

Parameters
messagemail message.
Returns
0 on success, -1 on failure.

◆ setCaFile()

template<class Protocol >
int join::BasicSmtpClient< Protocol >::setCaFile ( const std::string & caFile)
inline

set the location of the trusted CA certificate file.

Parameters
caFilepath of the trusted CA certificate file.
Returns
0 on success, -1 on failure.

◆ setCaPath()

template<class Protocol >
int join::BasicSmtpClient< Protocol >::setCaPath ( const std::string & caPath)
inline

set the location of the trusted CA certificates.

Parameters
caPathpath of the trusted CA certificates.
Returns
0 on success, -1 on failure.

◆ setCertificate()

template<class Protocol >
int join::BasicSmtpClient< Protocol >::setCertificate ( const std::string & cert,
const std::string & key = "" )
inline

set the certificate and the private key.

Parameters
certcertificate path.
keyprivate key path.
Returns
0 on success, -1 on failure.

◆ setCipher()

template<class Protocol >
int join::BasicSmtpClient< Protocol >::setCipher ( const std::string & cipher)
inline

set the cipher list (TLSv1.2 and below).

Parameters
cipherthe cipher list.
Returns
0 on success, -1 on failure.

◆ setCipher_1_3()

template<class Protocol >
int join::BasicSmtpClient< Protocol >::setCipher_1_3 ( const std::string & cipher)
inline

set the cipher list (TLSv1.3).

Parameters
cipherthe cipher list.
Returns
0 on success, -1 on failure.

◆ setVerify()

template<class Protocol >
void join::BasicSmtpClient< Protocol >::setVerify ( bool verify,
int depth = -1 )
inline

Enable/Disable the verification of the peer certificate.

Parameters
verifyEnable peer verification if set to true, false otherwise.
depthThe maximum certificate verification depth (default: no limit).

◆ startTls()

template<class Protocol >
int join::BasicSmtpClient< Protocol >::startTls ( )
inlineprotected

start encryption.

Returns
0 on success, -1 on failure.

◆ url()

template<class Protocol >
std::string join::BasicSmtpClient< Protocol >::url ( ) const
inline

get URL.

Returns
URL.

Member Data Documentation

◆ _host

template<class Protocol >
std::string join::BasicSmtpClient< Protocol >::_host
protected

SMTP host.

◆ _login

template<class Protocol >
std::string join::BasicSmtpClient< Protocol >::_login
protected

SMTP login.

◆ _password

template<class Protocol >
std::string join::BasicSmtpClient< Protocol >::_password
protected

SMTP password.

◆ _port

template<class Protocol >
uint16_t join::BasicSmtpClient< Protocol >::_port
protected

SMTP port.

◆ _stream

template<class Protocol >
Stream join::BasicSmtpClient< Protocol >::_stream
protected

stream.


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