Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Examples  

my_smtp.h File Reference

Go to the source code of this file.

Data Structures

struct  smtp_connexion_config
 This structure defines the information used by the SMTP client to connect to the server. More...

struct  smtp_mail
 This structure defines the information used by the SMTP client to send an e-mail. More...

struct  smtp_res
 This structure defines the information returned by all client SMTP functions. More...

struct  smtp_response
 This structure contains the information included in the answer from a SMTP server. More...


Defines

#define SMTP_ID_SIZE   1034
 Maximum number of characters for the client identification (HELO command).

#define SMTP_EMAIL_SIZE_MAX   1024
 Maximum number of characters for an e-mail address.

#define SMTP_RCPT_MAX   128
 Maximum number of recipients for a given mail.

#define SMTP_HOSTNAME_SIZE   512
 Maximum number of characters for a host name.

#define SMTP_WRITE_ERROR   -100
 Return balues for all the SMTP API. This means that the system call write() failed.

#define SMTP_BAD_ANSWER   -101
 Return balues for all the SMTP API. This means that the response from the SMTP server was not valid.

#define SMTP_BUFFER_OVERFLOW   -102
 Return balues for the function smtp_send_email(). This means that one of the input arguments "from" or "rcpt" is too long.

#define SMTP_BUFFER_SIZE   1024
 Size of the buffer used to receive/send data from/to the SMTP server.

#define SMTP_SERVER_IDENTIFICATION_OK   220
 Return value for the function response_parser(). The SMTP server returned "220 ...".

#define SMTP_CLIENT_IDENTIFICATION_OK   250
 Return value for the function response_parser(). The SMTP server returned "250 ...".

#define SMTP_FROM_OK   250
 Return value for the function response_parser(). The SMTP server returned "250 ...".

#define SMTP_RCPT_OK   250
 Return value for the function response_parser(). The SMTP server returned "250 ...".

#define SMTP_DATA_OK   354
 Return value for the function response_parser(). The SMTP server returned "354 ...".

#define SMTP_END_OF_DATA_OK   250
 Return value for the function response_parser(). The SMTP server returned "250 ...".

#define SMTP_INVALID_ANSWER   -1
 Return value for the function response_parser(). The SMTP server an invalid response.

#define SMTP_FROM_TAG_START   "MAIL FROM:<"
#define SMTP_FROM_TAG_STOP   ">\r\n"
#define SMTP_RCPT_TAG_START   "RCPT TO:<"
#define SMTP_RCPT_TAG_STOP   ">\r\n"
#define MY_SMTP_HEADER

Functions

int client_smtp_connect (struct smtp_connexion_config *conf, struct smtp_res *result)
 Open a connexion to the SMTP server.

void smtp_disconnect ()
 Close the connexion between the SMTP client ant the server.

int smtp_send_email (struct smtp_connexion_config *conf, struct smtp_mail *email, struct smtp_res *result)
 Send an email to the SMTP server.


Detailed Description

Header file for the smtp.c

Definition in file my_smtp.h.


Function Documentation

int client_smtp_connect struct smtp_connexion_config   conf,
struct smtp_res   result
 

Open a connexion to the SMTP server.

Parameters:
conf Pointer to a configuration structure.
result Pointer to smtp_res structure.
Returns:
Upon successful completion, the function returns a positive number that represents the socket descriptor associated with the connexion. In this case, the field ellapsed contains the ellapsed time of the connexion in milli-seconds.
Otherwise the function returns the value -1. In this case the field error_code of result contains a value that identifies the failure. This value may be:

  • An error code from the function open_tcp_connexion() (of the Common C Library). See the detailed description of open_tcp_connexion() for full details.
  • An error code from the function read_from_socket()(of the Common C Library). See the detailed description of read_from_socket() for full details.
  • The value SMTP_WRITE_ERROR. This means that the system call write failed.
  • The value SMTP_BAD_ANSWER. This means that the response from the SMTP server was not valid.

Definition at line 93 of file smtp.c.

References smtp_connexion_config::connect_timeout_micro, smtp_connexion_config::connect_timeout_sec, smtp_res::ellapsed, smtp_res::error_code, smtp_connexion_config::host, smtp_connexion_config::id, open_tcp_connexion(), smtp_connexion_config::port, read_from_socket(), smtp_connexion_config::read_timeout_micro, smtp_connexion_config::read_timeout_sec, response_parser(), SCK_READ_OK, SMTP_BAD_ANSWER, SMTP_BUFFER_SIZE, SMTP_CLIENT_IDENTIFICATION_OK, smtp_disconnect(), SMTP_SERVER_IDENTIFICATION_OK, SMTP_WRITE_ERROR, tcp_add, and tcp_sock.

int smtp_send_email struct smtp_connexion_config   conf,
struct smtp_mail   email,
struct smtp_res   result
 

Send an email to the SMTP server.

Parameters:
conf Pointer to a configuration structure.
email Pointer to a smtp_mail structure that contains the mail's data.
result Pointer to smtp_res structure.
Returns:
Upon successfull completion the function returns 0, therwise it returns -1 and the connexion is closed.
If the returned value is 0 (success), then the field ellapsed of the structure pointed by result contains the ellapsed time of the action in milli-seconds.

If the returned value is -1 (error), then the field error_code of the structure pointed by result contains an error code that describes the failure. This value may be:

  • An error code from the function read_from_socket()(of the Common C Library). See the detailed description of read_from_socket() for full details.
  • The value SMTP_WRITE_ERROR. This means that the system call write failed.
  • The value SMTP_BAD_ANSWER. This means that the response from the SMTP server was not valid.
  • The value SMTP_BUFFER_OVERFLOW. This means that one of the input arguments "from" or "rcpt" is too long.

Definition at line 257 of file smtp.c.

References smtp_mail::data, smtp_res::ellapsed, smtp_res::error_code, smtp_mail::from, smtp_mail::rcpt, smtp_mail::rcpt_number, read_from_socket(), smtp_connexion_config::read_timeout_micro, smtp_connexion_config::read_timeout_sec, response_parser(), SCK_READ_OK, SMTP_BAD_ANSWER, SMTP_BUFFER_OVERFLOW, SMTP_BUFFER_SIZE, SMTP_DATA_OK, smtp_disconnect(), SMTP_END_OF_DATA_OK, SMTP_FROM_OK, SMTP_RCPT_OK, SMTP_WRITE_ERROR, and tcp_sock.


Generated on Thu Apr 3 16:23:46 2003 for Common_C_libraries by doxygen1.3-rc1