Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

/opentcp/include/inet/smtp/smtp_client.h File Reference


Detailed Description

Author:
Version:
1.0
Date:
9.8.2002
OpenTCP SMTP client function declarations, constants, etc.

Definition in file smtp_client.h.

Go to the source code of this file.

Defines

#define SMTPC_TOUT   20
#define SMTP_UNINITIALIZED   1
#define SMTP_CLOSED   2
#define SMTP_OPEN_REQUESTED   3
#define SMTP_CONNECTIONOPEN_SENT   4
#define SMTP_CONNECTION_OPENED   5
#define SMTP_SERVER_READY   6
#define SMTP_HELO_SENT   7
#define SMTP_HELO_ACKED   8
#define SMTP_MAILFROM_SENT   9
#define SMTP_MAILFROM_ACKED   10
#define SMTP_RCPTTO_SENT   11
#define SMTP_RCPTTO_ACKED   12
#define SMTP_DATAREQ_SENT   13
#define SMTP_DATAREQ_ACKED   14
#define SMTP_BODY_SENT   15
#define SMTP_SENDING_DATA   16
#define SMTP_DATAEND_REACHED   17
#define SMTP_DATAEND_SENT   18
#define SMTP_DATAEND_ACKED   19
#define SMTP_QUIT_SENT   20
#define SMTP_QUIT_ACKED   21
#define SMTP_CMD_SERVER_READY   '2' + '2' + '0'
#define SMTP_CMD_OK   '2' + '5' + '0'
#define SMTP_CMD_DATAOK   '3' + '5' + '4'
#define SMTP_CMD_QUITOK   '2' + '2' + '1'

Functions

INT8 smtpc_connect (UINT32, UINT16)
 Start E-mail sending procedure.

void smtpc_init (void)
 Initializes SMTP client.

UINT8 smtpc_getstate (void)
 Retrieves SMTP clients' state.

INT8 smtpc_getdomain (UINT8 *)
 Fills in local domain information.

INT8 smtpc_getsender (UINT8 *)
 Returns senders' e-mail address.

INT8 smtpc_getreceiver (UINT8 *)
 Returns receivers' e-mail address.

INT8 smtpc_getsubject (UINT8 *)
 Returns subject of the E-mail.

INT16 smtpc_getdata (UINT8 *, UINT16)
 Returns e-mail data (message) to be sent.

void smtpc_dataacked (void)
 Last data received by remote host.

void smtpc_error (void)
 SMTP client error handler.

void smtpc_allok (void)
 SMTP client success handler.


Define Documentation

#define SMTPC_TOUT   20
 

SMTP clients' timeout in seconds

Definition at line 71 of file smtp_client.h.

#define SMTP_UNINITIALIZED   1
 

SMTP Client state: Not initialized yet

Definition at line 78 of file smtp_client.h.

#define SMTP_CLOSED   2
 

SMTP Client state: TCP connection closed

Definition at line 79 of file smtp_client.h.

Referenced by smtpc_connect(), and smtpc_init().

#define SMTP_OPEN_REQUESTED   3
 

SMTP Client state: User has requested mail read

Definition at line 80 of file smtp_client.h.

Referenced by smtpc_connect().

#define SMTP_CONNECTIONOPEN_SENT   4
 

SMTP Client state: TCP connection request sent

Definition at line 81 of file smtp_client.h.

#define SMTP_CONNECTION_OPENED   5
 

SMTP Client state: TCP Connection opened

Definition at line 82 of file smtp_client.h.

#define SMTP_SERVER_READY   6
 

SMTP Client state: SMTP server has indicated 220

Definition at line 83 of file smtp_client.h.

#define SMTP_HELO_SENT   7
 

SMTP Client state: HELO sent by us

Definition at line 84 of file smtp_client.h.

#define SMTP_HELO_ACKED   8
 

SMTP Client state: Server has acked HELO by 250

Definition at line 85 of file smtp_client.h.

#define SMTP_MAILFROM_SENT   9
 

SMTP Client state: MAIL FROM sent by us

Definition at line 86 of file smtp_client.h.

#define SMTP_MAILFROM_ACKED   10
 

SMTP Client state: Server has acked MAIL FROM by 250

Definition at line 87 of file smtp_client.h.

#define SMTP_RCPTTO_SENT   11
 

SMTP Client state: RCPT To sent by us

Definition at line 88 of file smtp_client.h.

#define SMTP_RCPTTO_ACKED   12
 

SMTP Client state: Server has acked RCPT TO by 250

Definition at line 89 of file smtp_client.h.

#define SMTP_DATAREQ_SENT   13
 

SMTP Client state: DATA sent by us

Definition at line 90 of file smtp_client.h.

#define SMTP_DATAREQ_ACKED   14
 

SMTP Client state: Server has acked DATA by 354

Definition at line 91 of file smtp_client.h.

#define SMTP_BODY_SENT   15
 

SMTP Client state: We have sent RFC822 body

Definition at line 92 of file smtp_client.h.

#define SMTP_SENDING_DATA   16
 

SMTP Client state: We are sending data...

Definition at line 93 of file smtp_client.h.

#define SMTP_DATAEND_REACHED   17
 

SMTP Client state: We have no more data

Definition at line 94 of file smtp_client.h.

#define SMTP_DATAEND_SENT   18
 

SMTP Client state: CRLF.CRLF sent by us

Definition at line 95 of file smtp_client.h.

#define SMTP_DATAEND_ACKED   19
 

SMTP Client state: Server has acked CRLF.CRLF by 250

Definition at line 96 of file smtp_client.h.

#define SMTP_QUIT_SENT   20
 

SMTP Client state: QUIT sent by us

Definition at line 97 of file smtp_client.h.

#define SMTP_QUIT_ACKED   21
 

SMTP Client state: Server has acked quit by 221

Definition at line 98 of file smtp_client.h.

#define SMTP_CMD_SERVER_READY   '2' + '2' + '0'
 

Server outputs when connected

Definition at line 103 of file smtp_client.h.

#define SMTP_CMD_OK   '2' + '5' + '0'
 

Command executed OK

Definition at line 104 of file smtp_client.h.

#define SMTP_CMD_DATAOK   '3' + '5' + '4'
 

OK to send data

Definition at line 105 of file smtp_client.h.

#define SMTP_CMD_QUITOK   '2' + '2' + '1'
 

OK to quit, close connection

Definition at line 106 of file smtp_client.h.


Function Documentation

INT8 smtpc_connect UINT32    ip,
UINT16    port
 

Author:
Date:
12.08.2002
Parameters:
ip  IP address of SMTP server
port  Port number on server (remote port)
Returns:
  • - 1 - Error
  • >=0 - Connection procedure started (OK)
This function is called by user when she wants to start E-mail sending procedure. The function is responsible of establishing connection to SMTP server. After connection is established the SMTP client engine starts to make callbacks to user functions in order to get E-mail address information, data etc.

Definition at line 120 of file smtp_client.c.

References smtp_client, SMTP_CLOSED, and SMTP_OPEN_REQUESTED.

void smtpc_init void   
 

Author:
Date:
12.08.2002
This function should be called once when system starts. Make sure that system services e.g. timers, TCP are initialized before initializing applications!

Definition at line 155 of file smtp_client.c.

References get_timer(), RESET_SYSTEM, smtp_client, SMTP_CLOSED, smtpc_init_done, TCP_APP_OFFSET, TCP_DEF_TOUT, tcp_getsocket(), TCP_TOS_NORMAL, and TCP_TYPE_CLIENT.

UINT8 smtpc_getstate void   
 

Author:
Date:
6.10.2002
Returns the state of SMTP client

Definition at line 193 of file smtp_client.c.

References smtp_client.

INT8 smtpc_getdomain UINT8 *    dbuf
 

Author:
Date:
12.08.2002
Parameters:
dbuf  pointer to buffer to which the domain name will be stored
Returns:
  • -1 - Error
  • >0 - Number of bytes inserted
This callback function is called by SMTP Client when it wants to know the local domain. The user is responsible of storing that domain to destbuf without NULL termination ('\0') and returning number of bytes on domain.

Definition at line 120 of file smtpc_callbacks.c.

INT8 smtpc_getsender UINT8 *    dbuf
 

Author:
Date:
12.08.2002
Parameters:
dbuf  pointer to buffer to which the sender will be stored
Returns:
  • -1 - Error
  • >0 - Number of bytes inserted
This callback function is called by SMTP Client when it wants to know the E-mail address of sender. The user is responsible of storing that address to destbuf without NULL termination ('\0') and returning number of bytes on E-mail address.

Definition at line 139 of file smtpc_callbacks.c.

INT8 smtpc_getreceiver UINT8 *    dbuf
 

Author:
Date:
12.08.2002
Parameters:
dbuf  pointer to buffer to which the receiver will be stored
Returns:
  • -1 - Error
  • >0 - Number of bytes inserted
This callback function is called by SMTP Client when it wants to know the E-mail address of receiver. The user is responsible of storing that address to destbuf without NULL termination ('\0') and returning number of bytes on E-mail address.

Definition at line 159 of file smtpc_callbacks.c.

INT8 smtpc_getsubject UINT8 *    dbuf
 

Author:
Date:
12.08.2002
Parameters:
dbuf  pointer to buffer to which the subject will be stored
Returns:
  • -1 - Error
  • >0 - Number of bytes inserted
This callback function is called by SMTP Client when it wants to know the subject of E-mail to be sent. The user is responsible of storing subject to destbuf without NULL termination ('\0') and returning number of bytes inserted.

Definition at line 178 of file smtpc_callbacks.c.

INT16 smtpc_getdata UINT8 *    dbuf,
UINT16    buflen
 

Author:
Date:
12.08.2002
Parameters:
dbuf  pointer to buffer to which the data will be stored
buflen  length of data buffer
Returns:
  • -1 - Error
  • >0 - Number of bytes inserted
This callback function is called by SMTP Client when it wants to get mail plain data from user. The user is responsible of filling dbuf and returning number of bytes assembled. When data end is reached the function must return (-1) without storing any bytes to buffer (so just send data untill you don't have any bytes to sent when callback is made to that function and return -1). Do not move read pointer of your data forward before SMTP makes callback to smtpc_dataacked!

Definition at line 203 of file smtpc_callbacks.c.

void smtpc_dataacked void   
 

Author:
Date:
12.08.2002
This callback function is called by SMTP Client when TCP has ensured that the last packet was transmitted succesfully and next time when smtpc_getdata callback is made new data should be assembled

Definition at line 219 of file smtpc_callbacks.c.

void smtpc_error void   
 

Author:
Date:
20.08.2002
This callback function is called by SMTP Client when there happens error of some kind (timeout, losing of connection etc.). It indicates that e-mail was not delivered to server.

Definition at line 84 of file smtpc_callbacks.c.

void smtpc_allok void   
 

Author:
Date:
12.08.2002
This callback function is called by SMTP Client when the packet is succesfully delivered to E-mail server.

Definition at line 99 of file smtpc_callbacks.c.


Generated on Sun Aug 3 20:33:00 2003 for OpenTCP by doxygen1.2.18