#include <SmtpClient.h>

Inheritance diagram for SmtpClient:
Collaboration diagram for SmtpClient:

Public Member Functions

 SmtpClient (bool autoDestroy=false)
 
 ~SmtpClient ()
 
bool connect (const Url &url)
 Connects to remote URL. More...
 
bool send (MailMessage *message)
 Powerful method to queues a single message before it is sent later to the SMTP server. More...
 
MailMessagegetCurrentMessage ()
 Gets the current message. More...
 
size_t countPending ()
 
void quit ()
 Sends a quit command to the server and closes the TCP connection. More...
 
SmtpState getState ()
 Returns the current state of the SmtpClient. More...
 
void onMessageSent (SmtpClientCallback callback)
 Callback that will be called every time a message is sent successfully. More...
 
void onServerError (SmtpClientCallback callback)
 Callback that will be called every an error occurs. More...
 
bool send (const String &from, const String &to, const String &subject, const String &body)
 Queues a single message before it is sent later to the SMTP server. More...
 
bool send (const String &from, const String &to, const String &subject, String &&body) noexcept
 

Protected Member Functions

err_t onReceive (pbuf *buf) override
 
void onReadyToSendData (TcpConnectionEvent sourceEvent) override
 
void sendMailHeaders (MailMessage *mail)
 
bool sendMailBody (MailMessage *mail)
 
- Protected Member Functions inherited from TcpClient
err_t onConnected (err_t err) override
 
err_t onReceive (pbuf *buf) override
 
err_t onSent (uint16_t len) override
 
void onError (err_t err) override
 
void onClosed () override
 Gets called when there is/was a tcp connection, the latter does not have to be established, that is closed due to error or normal disconnect. More...
 
void onReadyToSendData (TcpConnectionEvent sourceEvent) override
 
virtual void onFinished (TcpClientState finishState)
 
void pushAsyncPart ()
 
void freeStreams ()
 
 TcpClient (bool autoDestruct)
 
 TcpClient (tcp_pcb *clientTcp, TcpClientDataDelegate clientReceive, TcpClientCompleteDelegate onCompleted)
 
 TcpClient (TcpClientCompleteDelegate onCompleted, TcpClientEventDelegate onReadyToSend, TcpClientDataDelegate onReceive=nullptr)
 
 TcpClient (TcpClientCompleteDelegate onCompleted, TcpClientDataDelegate onReceive=nullptr)
 
 TcpClient (TcpClientDataDelegate onReceive)
 
 ~TcpClient ()
 
bool connect (const String &server, int port, bool useSsl=false) override
 
bool connect (IpAddress addr, uint16_t port, bool useSsl=false) override
 
void close () override
 
void setReceiveDelegate (TcpClientDataDelegate receiveCb=nullptr)
 Set or clear the callback for received data. More...
 
void setCompleteDelegate (TcpClientCompleteDelegate completeCb=nullptr)
 Set or clear the callback for connection close. More...
 
bool send (const char *data, uint16_t len, bool forceCloseAfterSent=false)
 
bool sendString (const String &data, bool forceCloseAfterSent=false)
 
bool send (IDataSourceStream *source, bool forceCloseAfterSent=false)
 Sends data stream. More...
 
bool isProcessing ()
 
TcpClientState getConnectionState ()
 
void setCloseAfterSent (bool ignoreIncomingData=false)
 
void commit ()
 Tries to send the pending data immediately. More...
 
- Protected Member Functions inherited from TcpConnection
void initialize (tcp_pcb *pcb)
 
bool internalConnect (IpAddress addr, uint16_t port)
 
bool sslCreateSession ()
 
virtual void sslInitSession (Ssl::Session &session)
 Override in inherited classes to perform custom session initialisation. More...
 
virtual err_t onPoll ()
 
void trySend (TcpConnectionEvent event)
 
err_t internalOnConnected (err_t err)
 
err_t internalOnReceive (pbuf *p, err_t err)
 
err_t internalOnSent (uint16_t len)
 
err_t internalOnPoll ()
 
void internalOnError (err_t err)
 
void internalOnDnsResponse (const char *name, LWIP_IP_ADDR_T *ipaddr, int port)
 
 TcpConnection (bool autoDestruct)
 
 TcpConnection (tcp_pcb *connection, bool autoDestruct)
 
virtual ~TcpConnection ()
 
void setAutoSelfDestruct (bool state)
 
int writeString (const char *data, uint8_t apiflags=TCP_WRITE_FLAG_COPY)
 Writes string data directly to the TCP buffer. More...
 
int writeString (const String &data, uint8_t apiflags=TCP_WRITE_FLAG_COPY)
 Writes string data directly to the TCP buffer. More...
 
virtual int write (const char *data, int len, uint8_t apiflags=TCP_WRITE_FLAG_COPY)
 Base write operation. More...
 
int write (IDataSourceStream *stream)
 Writes stream data directly to the TCP buffer. More...
 
uint16_t getAvailableWriteSize ()
 
void flush ()
 
void setTimeOut (uint16_t waitTimeOut)
 
IpAddress getRemoteIp () const
 
uint16_t getRemotePort () const
 
void setDestroyedDelegate (TcpConnectionDestroyedDelegate destroyedDelegate)
 Sets a callback to be called when the object instance is destroyed. More...
 
void setSslInitHandler (Ssl::Session::InitDelegate handler)
 Set the SSL session initialisation callback. More...
 
bool setSslConnection (Ssl::Connection *connection)
 
Ssl::SessiongetSsl ()
 Get a pointer to the current SSL session object. More...
 
- Protected Member Functions inherited from IpConnection
bool joinMulticastGroup (IpAddress localIp, IpAddress multicastIp)
 Uses IGMP to add a local network interface to multicast group. More...
 
bool joinMulticastGroup (IpAddress multicastIp)
 Uses IGMP to add all local network interfaces to multicast group. More...
 
bool leaveMulticastGroup (IpAddress localIp, IpAddress multicastIp)
 Uses IGMP to remove a local network interface from multicast group. More...
 
bool leaveMulticastGroup (IpAddress multicastIp)
 Uses IGMP to remove all local network interfaces from multicast group. More...
 

Additional Inherited Members

- Protected Attributes inherited from TcpClient
IDataSourceStreamstream = nullptr
 The currently active stream being sent. More...
 
- Protected Attributes inherited from TcpConnection
tcp_pcb * tcp = nullptr
 
uint16_t sleep = 0
 
uint16_t timeOut = USHRT_MAX
 By default a TCP connection does not have a time out. More...
 
bool canSend = true
 
bool autoSelfDestruct = true
 
Ssl::Sessionssl = nullptr
 
Ssl::Session::InitDelegate sslInit
 
bool useSsl = false
 

Constructor & Destructor Documentation

◆ SmtpClient()

SmtpClient::SmtpClient ( bool  autoDestroy = false)
inline

◆ ~SmtpClient()

SmtpClient::~SmtpClient ( )

Member Function Documentation

◆ connect()

bool SmtpClient::connect ( const Url url)

Connects to remote URL.

Parameters
urlProvides the protocol, remote server, port and user credentials allowed protocols:
  • smtp - clear text SMTP
  • smtps - SMTP over SSL connection

◆ countPending()

size_t SmtpClient::countPending ( )
inline

◆ getCurrentMessage()

MailMessage* SmtpClient::getCurrentMessage ( )

Gets the current message.

Return values
MailMessage*The message, or NULL if none is scheduled

◆ getState()

SmtpState SmtpClient::getState ( )
inline

Returns the current state of the SmtpClient.

◆ onMessageSent()

void SmtpClient::onMessageSent ( SmtpClientCallback  callback)
inline

Callback that will be called every time a message is sent successfully.

Parameters
callback

◆ onReadyToSendData()

void SmtpClient::onReadyToSendData ( TcpConnectionEvent  sourceEvent)
overrideprotectedvirtual

Reimplemented from TcpConnection.

◆ onReceive()

err_t SmtpClient::onReceive ( pbuf *  buf)
overrideprotectedvirtual

Reimplemented from TcpConnection.

◆ onServerError()

void SmtpClient::onServerError ( SmtpClientCallback  callback)
inline

Callback that will be called every an error occurs.

Parameters
callback

◆ quit()

void SmtpClient::quit ( )

Sends a quit command to the server and closes the TCP connection.

◆ send() [1/3]

bool SmtpClient::send ( const String from,
const String to,
const String subject,
const String body 
)

Queues a single message before it is sent later to the SMTP server.

Parameters
from
to
subject
bodyThe body in plain text format
Return values
booltrue when the message was queued successfully, false otherwise

◆ send() [2/3]

bool SmtpClient::send ( const String from,
const String to,
const String subject,
String &&  body 
)
noexcept

◆ send() [3/3]

bool SmtpClient::send ( MailMessage message)

Powerful method to queues a single message before it is sent later to the SMTP server.

Parameters
message
Return values
booltrue when the message was queued successfully, false otherwise

◆ sendMailBody()

bool SmtpClient::sendMailBody ( MailMessage mail)
protected

◆ sendMailHeaders()

void SmtpClient::sendMailHeaders ( MailMessage mail)
protected

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