tfSmtpUserExecute

Jump to: navigation, search

Table of Contents >> Optional Protocols >> SMTP


#include <trsocket.h>


int tfSmtpUserExecute (ttSmtpClientHandle smtpClientHandle);


Note Note: This function should only be called when the SMTP session is operating in non-blocking mode.


Function Description

The user needs to call this function in the application code periodically after an SMTP API call has been made. This allows SMTP to check on the command completion and timeout conditions. When the a command has finished, or a timeout has occurred, the user callback function will be called from tfSmtpUserExecute() with the appropriate event as shown in the table below.


In the call back function, events should be processed as follows:

Event Your Action
TM_SMTP_EVENT_CONNECTED Call tfSmtpUserSendSenderInfo().
TM_SMTP_EVENT_SENDER_ACK Call tfSmtpUserSendRecipientInfo().
TM_SMTP_EVENT_RECIPIENT_ACK Call tfSmtpUserSendBom() (or tfSmtpUserSendRecipientInfo() to provide additional recipients).
TM_SMTP_EVENT_BOM_ACK Call tfSmtpUserSendBody() zero or more times, then call tfSmtpUserSendEom().
TM_SMTP_EVENT_EOM_ACK Call tfSmtpUserDisconnect() (or tfSmtpUserSendSenderInfo() to send again).
TM_SMTP_EVENT_DISCONNECTED Notify foreground code that the mail message was sent successfully and the connection is closed.
TM_SMTP_EVENT_SERVER_ERROR Notify foreground code that a permanent error occurred (i.e. server replied with a 5xx response code). If the server rejects one of your recipients with this event and you have more recipients, call tfSmtpUserSendRecipientInfo() with the next email address.
TM_SMTP_EVENT_SERVER_RETRY Notify foreground code that a temporary error occurred (i.e. server replied with a 4xx response code). If the server rejects one of your recipients with this event and you have more recipients, call tfSmtpUserSendRecipientInfo() with the next email address.
TM_SMTP_EVENT_TIMEOUT Notify foreground code that the operation has timed out. The connection will be closed. Call tfSmtpUserConnect() to reconnect.
TM_SMTP_EVENT_AUTH_OK Notify foreground code that the SMTP server has accepted your login credentials.
TM_SMTP_EVENT_AUTH_FAIL Notify foreground code that the SMTP server has rejected your login credentials. Authentication happens during connection. Call tfSmtpUserDisconnect() then tfSmtpUserConnect() to reconnect with different credentials.
TM_SMTP_EVENT_SECURE_OK Notify foreground code that SSL/TLS negotiation with the SMTP server has succeeded and the SMTP session is secure.
TM_SMTP_EVENT_SECURE_FAIL Notify foreground code that SSL/TLS negotiation with the SMTP server has failed and the SMTP session is not secure.
TM_SMTP_EVENT_RESET Call tfSmtpUserSendSenderInfo() to send again. This event is a response to a tfSmtpUserReset() call.
TM_SMTP_EVENT_NOOP_ACK Notify foreground code that the server is OK. This event is a response to a tfSmtpUserSendNoop() call.


Parameters


Returns

  • TM_ENOERROR
    Success.
  • TM_EINPROGRESS
    The previous SMTP call is still in progress.
  • TM_EINVAL
    Invalid SMTP client session handle.
  • TM_EPERM
    The SMTP session is not connected or is operating in blocking mode.
  • TM_ESERVERPERM
    The server rejected the last command with a permanent negative completion reply (5xx status code, see RFC 5321).
  • TM_ESERVERTEMP
    The server rejected the last command with a transient negative completion reply (4xx status code, see RFC 5321).
  • TM_ESERVERSYNC
    The client and server are out of sync and cannot proceed; the session has been disconnected. This can occur, for example, if the server unexpectedly sends an intermediate reply (3xx status code, see RFC 5321) to a command that requires a completion code.
  • TM_ETIMEDOUT
    The Treck SMTP client timed out and disconnected while waiting for a reply from the server. The time limit is set via tfSmtpUserNewSession().
  • TM_ESHUTDOWN
    The server closed the connection, unexpectedly.
  • other errors
    Some socket errors returned from the SMTP client's calls to send() and recv() are passed directly to the caller.


Table of Contents >> Optional Protocols >> SMTP