This documentation is for the SMTPClient class in the Segundo Equipo version of the NetServices library. To be used in conjunction with the EmailMessage class.

To test, import the test program into the compiler and then edit the #define items:

#define SERVER "server"
#define PORT 25
#define USER "username"
#define PASSWORD "password"
#define DOMAIN ""
#define FROM_ADDRESS ""
#define TO_ADDRESS ""

Authentication and encryption

The SMTPClient supports plain authentication. This means that the username and password are encoded (but not encrypted) into base 64 for sending to the server.

The SMTPClient does not support encryption of the authentication credentials or the message content. The class will therefore not be suitable for use with an SMTP server that enforces use of, for example, SSL or TLS.

Import library

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.

Import library

Public Member Functions

  EmailMessage ()
  Instantiates the email message.
  ~EmailMessage ()
  Destructor for the email message.
void  setFrom (const char *from)
  Set FROM address.
void  addTo (const char *to)
  Add TO address to list of recipient addresses.
void  clearTo ()
  Clear TO addresses.
int  printf (const char *format,...)
  Append text to content of message using printf.
void  clearContent ()
  Clear content previously appended by printf.


class  SMTPClient

All wikipages