tfSmtpUserSendBody

Jump to: navigation, search

Table of Contents >> Optional Protocols >> SMTP


#include <trsocket.h>


int tfSmtpUserSendBody (
ttSmtpClientHandle smtpClientHandle,
char * bodyPtr,
int bodyLen,
int * errorCodePtr
);


Function Description

This function sends the message body. It can be called multiple times to aggregate a large mail message. This API needs to be called in the right state, otherwise, TM_EPERM will be returned. This function can take up to one full packet of data per call, which it will try to queue in the socket send buffer.

Unlike other SMTP API functions, tfSmtpUserSendBody() does not send a command or require a server reply. The command reply timer will not be active. Handshaking is purely TCP based until the server receives the end of message indication (tfSmtpUserSendEom()). Any timeout that occurs will be a result of TCP retransmission failure. The message will be buffered up to the socket send queue size before blocking or returning TM_EINPROGRESS. Transmission from the socket send queue is paced by the server reading the data from its socket endpoint.


Blocking Mode

If the session is operating in blocking mode, this function should be called after tfSmtpUserSendBom() or tfSmtpUserSendBody() has returned TM_ENOERROR and no other API has been called.


Non-blocking Mode

If the session is operating in non-blocking mode, this function should be called the first time when the event TM_SMTP_EVENT_BOM_ACK is received. Thereafter tfSmtpUserSendBody() can be called multiple times with no call back event, and no call to tfSmtpUserExecute(). When tfSmtpUserSendBody() returns, and the error code pointed to by errorCodePtr is set to TM_EINPROGRESS, then tfSmtpUserExecute() should be called until it no longer returns TM_EINPROGRESS.


Parameters

  • smtpClientHandle
    The SMTP client session handle as returned by tfSmtpUserNewSession().
  • bodyPtr
    A pointer to a string that holds the mail message.
  • bodyLen
    The length of the string pointed to by bodyPtr.
  • errorCodePtr
    Upon return, *errorCodePtr contains the error code. See below for possible values.


Returns

  • >0
    The length of the message actually sent to the SMTP server. This could be smaller than the value specified by bodyLen. The user should call tfSmtpUserSendBody() again to send the rest of the message.
  • TM_SOCKET_ERROR
    Failure. Check *errorCodePtr for more details.


Possible *errorCodePtr Values

  • TM_ENOERROR
    Success.
  • TM_EINPROGRESS
    In non blocking mode, indicates that tfSmtpUserExecute() should be called until it no longer returns TM_EINPROGRESS .
  • TM_EINVAL
    Invalid SMTP client session handle, bodyPtr is NULL or bodyLen is 0.
  • TM_ETIMEDOUT
    The TCP connection is broken.
  • TM_EPERM
    The SMTP session is not connected.
  • TM_ENOBUFS
    Insufficient resources to complete the operation.


Table of Contents >> Optional Protocols >> SMTP