# Embedded SMTP Client

Topics

:

Overview
Data Members
Functions

Overview

The embedded SMTP (Simple Mail Transfer Protocol) client is a cross platform SMTP implementation used with applications that require SMTP client/server functions. The gxsSMTPClient class is derived from the gxSocket class and conforms to RFC 821: http://www.faqs.org/rfcs/rfc821.html

Public Data Members

char gxsSMTPClient:: reply_buf[gxsBUF_SIZE]

- Buffer used to hold the last reply.

char gxsSMTPClient:: command_buf[gxsBUF_SIZE]

- Buffer used to hold the last command.

int gxsSMTPClient:: time_out_sec

- Number of seconds before a blocking timeout.

int gxsSMTPClient:: time_out_usec

- Number of microseconds before a blocking timeout.

Functions

gxsSMTPClient::gxsSMTPClient()
gxsSMTPClient::~gxsSMTPClient()
gxsSMTPClient::ConnectClient()
gxsSMTPClient::GetSMTPTimeStamp()
gxsSMTPClient::RecvResponse()
gxsSMTPClient::SMTPData()
gxsSMTPClient::SMTPLogin()
gxsSMTPClient::SMTPLogout()
gxsSMTPClient::SMTPMailFrom()
gxsSMTPClient::SMTPRSet()
gxsSMTPClient::SMTPRcptTo()
gxsSMTPClient::SMTPSendMessage()
gxsSMTPClient::SendCommand()
gxsSMTPClient::SetTimeOut()
gxsSMTPClient::WaitForReply()

gxsSMTPClient::gxsSMTPClient()

- Default class constructor.

gxsSMTPClient::~gxsSMTPClient()

- Class destructor.

gxSocketError gxsSMTPClient::ConnectClient(const char *host, int port = gxSOCKET_SMTP_PORT)

-Public member function used to connect a SMTP client to a server. Returns zero if no errors occur.

void gxsSMTPClient::GetSMTPTimeStamp(char *sbuf)

- Public member function that passes back an SMTP time string in the following format:

    Weekday, Day Month Year HH:MM:SS - Timezone

NOTE

: The calling function should allocate memory for the "sbuf" variable. If "sbuf" variable is null this function will allocate memory for the time stamp string, which must be freed by the caller.

int gxsSMTPClient::RecvResponse(char *buf, int bytes, const char *response)

- Public Blocking receive function used to read a reply from an SMTP server following a command. If the specified response is not received within the timeout period this function will return false to indicate an error. Returns true if successful.

gxSocketError gxsSMTPClient::SMTPData(const char *body_text, int body_len)

- Public member function used to send a text body. Returns zero if no errors occur.

gxSocketError gxsSMTPClient::SMTPLogin(const char *local_host_name)

- Public member function used to send the SMTP "Hello" command. The "local_host_name" variable must be a null terminated string set to either your domain name or fully qualified host name. Returns zero if no errors occur.

gxSocketError gxsSMTPClient::SMTPLogout()

- Public member function used to send the SMTP "QUIT" command. Returns zero if no errors occur.

gxSocketError gxsSMTPClient::SMTPMailFrom(const char *from_email_address)

- Public member function used to send the SMTP "MAIL FROM" command. The "from_email_address" variable must be a null terminated string set to your return email address. Returns zero if no errors occur.

gxSocketError gxsSMTPClient::SMTPRSet()

- Public member function used to send the SMTP "Reset" command. Returns zero if no errors occur.

gxSocketError gxsSMTPClient::SMTPRcptTo(const char *to_email_address)

- Public member function used to send the SMTP "RCPT TO" command. The "to_email_address" variable must be a null terminated string set to a valid email recipient. Returns zero if no errors occur.

gxSocketError gxsSMTPClient::SMTPSendMessage(const char *to, const char *from, const char *subject, const char *body)

- Public member function used to send a formatted email message. The "to", "from", "subject", and "body" variable must be null terminated strings set to a valid email recipient, your return email address, a subject, and a message body. Returns zero if no errors occur.

gxSocketError gxsSMTPClient::SendCommand(const char *command, const char *response, const char *args = 0)

- Public member function used to send a command to an SMTP server and read the server's response. Returns zero if no errors occur.

void gxsSMTPClient::SetTimeOut(int seconds, int useconds)

- Public member function used to set the SMTP timeout value.

int gxsSMTPClient::WaitForReply()

- Public member function that returns false if a reply time is longer then the timeout values.

End Of Document