#include <SmtpClient.h>
Public Member Functions | |
SmtpClient (bool autoDestroy=false) | |
~SmtpClient () | |
bool | connect (const Url &url) |
Connects to remote URL. 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 (MailMessage *message) |
Powerful method to queues a single message before it is sent later to the SMTP server. More... | |
MailMessage * | getCurrentMessage () |
Gets the current message. More... | |
size_t | countPending () |
void | quit () |
Sends a quit command to the server and closes the TCP conneciton. 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... | |
Protected Member Functions | |
err_t | onReceive (pbuf *buf) override |
void | onReadyToSendData (TcpConnectionEvent sourceEvent) override |
void | sendMailHeaders (MailMessage *mail) |
bool | sendMailBody (MailMessage *mail) |
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 | isProcessing () |
TcpClientState | getConnectionState () |
void | setCloseAfterSent (bool ignoreIncomingData=false) |
err_t | onConnected (err_t err) override |
err_t | onSent (uint16_t len) override |
void | onError (err_t err) override |
virtual void | onFinished (TcpClientState finishState) |
void | pushAsyncPart () |
void | freeStreams () |
void | setBuffer (ReadWriteStream *stream) |
int | writeString (const char *data, uint8_t apiflags=TCP_WRITE_FLAG_COPY) |
int | writeString (const String &data, uint8_t apiflags=TCP_WRITE_FLAG_COPY) |
virtual int | write (const char *data, int len, uint8_t apiflags=TCP_WRITE_FLAG_COPY) |
Base write operation. More... | |
int | write (IDataSourceStream *stream) |
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::Session * | getSsl () |
Get a pointer to the current SSL session object. More... | |
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) |
Protected Attributes | |
ReadWriteStream * | buffer = nullptr |
Used internally to buffer arbitrary data via send() methods. More... | |
IDataSourceStream * | stream = nullptr |
The currently active stream being sent. More... | |
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::Session * | ssl = nullptr |
Ssl::Session::InitDelegate | sslInit |
bool | useSsl = false |
Constructor & Destructor Documentation
◆ SmtpClient()
SmtpClient::SmtpClient | ( | bool | autoDestroy = false | ) |
◆ ~SmtpClient()
SmtpClient::~SmtpClient | ( | ) |
Member Function Documentation
◆ close()
|
overridevirtualinherited |
Reimplemented from TcpConnection.
◆ connect() [1/3]
|
overridevirtualinherited |
Reimplemented from TcpConnection.
◆ connect() [2/3]
|
overridevirtualinherited |
Reimplemented from TcpConnection.
◆ connect() [3/3]
Connects to remote URL.
- Parameters
-
url Provides the protocol, remote server, port and user credentials allowed protocols: - smtp - clear text SMTP
- smtps - SMTP over SSL connection
◆ countPending()
|
inline |
◆ flush()
|
inherited |
◆ freeStreams()
|
protectedinherited |
◆ getAvailableWriteSize()
|
inlineinherited |
◆ getConnectionState()
|
inlineinherited |
◆ getCurrentMessage()
MailMessage* SmtpClient::getCurrentMessage | ( | ) |
Gets the current message.
- Return values
-
MailMessage* The message, or NULL if none is scheduled
◆ getRemoteIp()
|
inlineinherited |
◆ getRemotePort()
|
inlineinherited |
◆ getSsl()
|
inlineinherited |
Get a pointer to the current SSL session object.
Note that this is typically used so we can query properties of an established session. If you need to change session parameters this must be done via setSslInitHandler
.
◆ getState()
|
inline |
Returns the current state of the SmtpClient.
◆ initialize()
|
protectedinherited |
◆ internalConnect()
◆ internalOnConnected()
|
protectedinherited |
◆ internalOnDnsResponse()
|
protectedinherited |
◆ internalOnError()
|
protectedinherited |
◆ internalOnPoll()
|
protectedinherited |
◆ internalOnReceive()
|
protectedinherited |
◆ internalOnSent()
|
protectedinherited |
◆ isProcessing()
|
inlineinherited |
◆ onConnected()
|
overrideprotectedvirtualinherited |
Reimplemented from TcpConnection.
◆ onError()
|
overrideprotectedvirtualinherited |
Reimplemented from TcpConnection.
◆ onFinished()
|
protectedvirtualinherited |
Reimplemented in MqttClient.
◆ onMessageSent()
|
inline |
Callback that will be called every time a message is sent successfully.
- Parameters
-
callback
◆ onPoll()
|
protectedvirtualinherited |
◆ onReadyToSendData()
|
overrideprotectedvirtual |
Reimplemented from TcpConnection.
◆ onReceive()
|
overrideprotectedvirtual |
Reimplemented from TcpConnection.
◆ onSent()
|
overrideprotectedvirtualinherited |
Reimplemented from TcpConnection.
◆ onServerError()
|
inline |
Callback that will be called every an error occurs.
- Parameters
-
callback
◆ pushAsyncPart()
|
protectedinherited |
◆ quit()
void SmtpClient::quit | ( | ) |
Sends a quit command to the server and closes the TCP conneciton.
◆ send() [1/3]
|
inherited |
◆ send() [2/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 body The body in plain text format
- Return values
-
bool true when the message was queued successfully, false otherwise
◆ 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
-
bool true when the message was queued successfully, false otherwise
◆ sendMailBody()
|
protected |
◆ sendMailHeaders()
|
protected |
◆ sendString()
|
inlineinherited |
◆ setBuffer()
|
protectedinherited |
◆ setCloseAfterSent()
|
inlineinherited |
Schedules the connection to get closed after the data is sent
- Parameters
-
ignoreIncomingData when that flag is set the connection will start ignoring incoming data.
◆ setCompleteDelegate()
|
inlineinherited |
Set or clear the callback for connection close.
- Parameters
-
completeCb callback delegate or nullptr
◆ setDestroyedDelegate()
|
inlineinherited |
Sets a callback to be called when the object instance is destroyed.
- Parameters
-
destroyedDelegate
◆ setReceiveDelegate()
|
inlineinherited |
Set or clear the callback for received data.
- Parameters
-
receiveCb callback delegate or nullptr
◆ setSslConnection()
|
inlineinherited |
◆ setSslInitHandler()
|
inlineinherited |
Set the SSL session initialisation callback.
- Parameters
-
handler
◆ setTimeOut()
|
inherited |
◆ sslCreateSession()
|
protectedinherited |
◆ sslInitSession()
|
inlineprotectedvirtualinherited |
Override in inherited classes to perform custom session initialisation.
Called when TCP connection is established before initiating handshake.
Reimplemented in HttpClientConnection.
◆ trySend()
|
inlineprotectedinherited |
◆ write() [1/2]
|
virtualinherited |
Base write operation.
- Parameters
-
data len apiflags TCP_WRITE_FLAG_COPY, TCP_WRITE_FLAG_MORE
- Return values
-
int -1 on error
Reimplemented in FtpDataStream.
◆ write() [2/2]
|
inherited |
◆ writeString() [1/2]
|
inlineinherited |
◆ writeString() [2/2]
|
inlineinherited |
Member Data Documentation
◆ autoSelfDestruct
|
protectedinherited |
◆ buffer
|
protectedinherited |
Used internally to buffer arbitrary data via send() methods.
◆ canSend
|
protectedinherited |
◆ sleep
|
protectedinherited |
◆ ssl
|
protectedinherited |
◆ sslInit
|
protectedinherited |
◆ stream
|
protectedinherited |
The currently active stream being sent.
◆ tcp
|
protectedinherited |
◆ timeOut
|
protectedinherited |
By default a TCP connection does not have a time out.
◆ useSsl
|
protectedinherited |
The documentation for this class was generated from the following file: