Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Email2Screen by
SMTPClient Class Reference
A simple SMTP Client. More...
#include <SMTPClient.h>
Inherits NetService.
Public Member Functions | |
SMTPClient () | |
Instantiates the SMTP client. | |
virtual | ~SMTPClient () |
Destructor for the SMTP client. | |
SMTPClient (const Host &host, const char *heloDomain, const char *user, const char *password, SMTPAuth auth) | |
Full constructor for the SMTP client. | |
void | setServer (const Host &host) |
Set server host. | |
void | setAuth (const char *user, const char *password) |
Provides a plain authentication feature (Base64 encoded username and password) | |
void | clearAuth () |
Turns off authentication. | |
void | setHeloDomain (const char *heloDomain) |
Set HELO domain (defaults to localhost if not set) | |
SMTPResult | send (EmailMessage *pMessage) |
Sends the message (blocking) | |
SMTPResult | send (EmailMessage *pMessage, void(*pMethod)(SMTPResult)) |
Sends the message (non blocking) | |
template<class T > | |
SMTPResult | send (EmailMessage *pMessage, T *pItem, void(T::*pMethod)(SMTPResult)) |
Sends the message (non blocking) | |
void | doSend (EmailMessage *pMessage) |
Sends the message (non blocking) | |
void | setOnResult (void(*pMethod)(SMTPResult)) |
Setup the result callback. | |
void | setTimeout (int ms) |
Setup timeout. | |
string & | getLastResponse () |
Gets the last response from the server. | |
virtual void | poll () |
This method can be inherited so that it is called on each Net::poll() call. | |
Protected Member Functions | |
void | close () |
This flags the service as to be destructed if owned by the pool. |
Detailed Description
A simple SMTP Client.
The SMTPClient is composed of:
- The actual client (SMTPClient)
- A class (EmailMessage) to hold the message addresses and content for sending
Definition at line 62 of file SMTPClient.h.
Constructor & Destructor Documentation
SMTPClient | ( | ) |
Instantiates the SMTP client.
Definition at line 36 of file SMTPClient.cpp.
~SMTPClient | ( | ) | [virtual] |
Destructor for the SMTP client.
Definition at line 56 of file SMTPClient.cpp.
SMTPClient | ( | const Host & | host, |
const char * | heloDomain, | ||
const char * | user, | ||
const char * | password, | ||
SMTPAuth | auth | ||
) |
Full constructor for the SMTP client.
- Parameters:
-
host : SMTP server host heloDomain : domain name of client user : username password : password auth : authentication type
Definition at line 46 of file SMTPClient.cpp.
Member Function Documentation
void clearAuth | ( | ) |
Turns off authentication.
Definition at line 66 of file SMTPClient.cpp.
void close | ( | ) | [protected] |
This flags the service as to be destructed if owned by the pool.
Reimplemented from NetService.
Definition at line 136 of file SMTPClient.cpp.
void doSend | ( | EmailMessage * | pMessage ) |
Sends the message (non blocking)
- Parameters:
-
pMessage : pointer to a message
The function returns immediately and calls the previously set callback on completion or error
Definition at line 98 of file SMTPClient.cpp.
string & getLastResponse | ( | ) |
Gets the last response from the server.
Definition at line 451 of file SMTPClient.cpp.
void poll | ( | ) | [virtual] |
This method can be inherited so that it is called on each Net::poll() call.
Reimplemented from NetService.
Definition at line 112 of file SMTPClient.cpp.
SMTPResult send | ( | EmailMessage * | pMessage ) |
Sends the message (blocking)
- Parameters:
-
pMessage : pointer to a message
Blocks until completion
Definition at line 87 of file SMTPClient.cpp.
SMTPResult send | ( | EmailMessage * | pMessage, |
T * | pItem, | ||
void(T::*)(SMTPResult) | pMethod | ||
) |
Sends the message (non blocking)
- Parameters:
-
pMessage : pointer to a message pItem : instance of class on which to execute the callback method pMethod : callback method
The function returns immediately and calls the callback on completion or error
Definition at line 129 of file SMTPClient.h.
SMTPResult send | ( | EmailMessage * | pMessage, |
void(*)(SMTPResult) | pMethod | ||
) |
Sends the message (non blocking)
- Parameters:
-
pMessage : pointer to a message pMethod : callback function
The function returns immediately and calls the callback on completion or error
Definition at line 92 of file SMTPClient.cpp.
void setAuth | ( | const char * | user, |
const char * | password | ||
) |
Provides a plain authentication feature (Base64 encoded username and password)
- Parameters:
-
user : username password : password
Definition at line 60 of file SMTPClient.cpp.
void setHeloDomain | ( | const char * | heloDomain ) |
Set HELO domain (defaults to localhost if not set)
- Parameters:
-
heloDomain : domain name of client (strictly should be fully qualified domain name)
Definition at line 83 of file SMTPClient.cpp.
void setOnResult | ( | void(*)(SMTPResult) | pMethod ) |
Setup the result callback.
- Parameters:
-
pMethod : callback function
Definition at line 102 of file SMTPClient.cpp.
void setServer | ( | const Host & | host ) |
void setTimeout | ( | int | ms ) |
Setup timeout.
- Parameters:
-
ms : time of connection inactivity in ms after which the request should timeout
Definition at line 108 of file SMTPClient.cpp.
Generated on Tue Jul 12 2022 14:12:38 by
