Dallas Semiconductor DS80C400 C Libraries Home Page

Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

tini400_smtp.h File Reference


Detailed Description

SMTP Library functions for DS80C400 processor.

This library contains functions for sending mails to smtp mailhost server

For detailed information on the DS80C400 please see the High-Speed Microcontroller User's Guide: DS80C400 Supplement.

Warning:
The functions in this library are NOT multi-process safe--that is, if you call the same method from two different processes at the same time, the parameters to the function may be destroyed, yielding unpredictable results.

Go to the source code of this file.

Data Structures

struct  _hostinfo
struct  _mailheader
struct  _userheader

Defines

#define MAX_LINE_SIZE   1024
#define SMTP_VERSION   3
#define SMTP_MAXATTACHMENTSIZE   5
#define SMTP_MAXUSERHEADERSIZE   20
#define SMTP_INSUFFICIENT_MEMORY   -1
#define SMTP_MAILHOST_NOT_FOUND   -3
#define SMTP_FILE_NOT_FOUND   -4
#define SMTP_SOCKET_ERROR   -7
#define SMTP_MAIL_QUEUED   -8
#define SMTP_INVALID_MAILNODE_ADDRESS   -9
#define SMTP_LIBRARY_IS_NOT_CONFIGURED   -11
#define SMTP_STATUS_SUCCESS   0

Typedefs

typedef _hostinfo hostinfo
typedef _mailheader mailheader
 Structure for standard mail header holds standard mail header values.
typedef _userheader userheader
 Structure for user defined mail header contains user header name list and user header value list.

Functions

void smtp_init (void)
 Initializes smtp library.
void smtp_sethostinfo (struct _hostinfo *phostinfo)
 Sets the host information object with smtp library.
void smtp_setclientsocktimeout (long milli_sec)
 Sets SMTP client socket timeout value.
long smtp_getclientsocktimeout (void)
 Returns the current value for SMTP client socket timeout.
void smtp_setdefaultheadervalue (struct _mailheader *pmhdr)
 Sets the default value for standard mail headers.
void smtp_setuserheaderlist (struct _userheader *pusrhdr)
 Sets user defined mail header list.
int smtp_sendmail (struct _mailheader mail_header, char *msg, char *attachmentlist[SMTP_MAXATTACHMENTSIZE], char queuemail_flag, unsigned long *mailnodeaddress)
 Sends mail to mail host.
int smtp_removemailfromqueue (unsigned long pmailnode_address)
 Removes queued mail from mail queue list.
int smtp_getqueuedmailstatus (unsigned long pmailnode_address)
 Returns the status of queued mail.


Define Documentation

#define MAX_LINE_SIZE   1024
 

Definition for maximum size of mail header

#define SMTP_FILE_NOT_FOUND   -4
 

File not found error value

See also:
smtp_sendmail

smtp_getqueuedmailstatus

#define SMTP_INSUFFICIENT_MEMORY   -1
 

Insufficient memory error value

See also:
smtp_sendmail

#define SMTP_INVALID_MAILNODE_ADDRESS   -9
 

Invalid mailnode address error value.

See also:
smtp_getqueuedmailstatus

smtp_removemailfromqueue

#define SMTP_LIBRARY_IS_NOT_CONFIGURED   -11
 

smtp library is not configured error value, this value will be returned if smtp host information is not configured.

See also:
smtp_sendmail

#define SMTP_MAIL_QUEUED   -8
 

Mail is queued error value

See also:
smtp_sendmail

smtp_getqueuedmailstatus

#define SMTP_MAILHOST_NOT_FOUND   -3
 

Mail host is not found error value

See also:
smtp_sendmail

smtp_getqueuedmailstatus

#define SMTP_MAXATTACHMENTSIZE   5
 

Definition for maximum number of attachments

See also:
smtp_sendmail

#define SMTP_MAXUSERHEADERSIZE   20
 

Definition for maximum number of user headers

See also:
smtp_sendmail

#define SMTP_SOCKET_ERROR   -7
 

Socket error value

See also:
smtp_sendmail

#define SMTP_STATUS_SUCCESS   0
 

smtp Status success value, this value is returned when operation is completed successfully.

See also:
smtp_sendmail

#define SMTP_VERSION   3
 

Version number associated with this header file. Should be the same as the version number returned by the smtp_version function.

See also:
smtp_version


Typedef Documentation

typedef struct _hostinfo hostinfo
 

Structure for host configuration information that has to be registered with smtp library


Function Documentation

long smtp_getclientsocktimeout void   ) 
 

Returns the current value for SMTP client socket timeout.

This function returns the current value for SMTP client socket timeout

This function is safe to be called from multiple processes at the same time.

Returns:
The current value for http client socket timeout

int smtp_getqueuedmailstatus unsigned long  pmailnode_address  ) 
 

Returns the status of queued mail.

This function returns the status of mail which was queued by smtp_sendmail.

Parameters:
pmailnode_address - address of mailnode. this value should be same value returned by smtp_sendmail function when queueing mail.
Returns:
if mail is still in queue, returns the status of mail. SMTP_INVALID_MAILNODE_ADDRESS if invalid mail node address is passed or mail has been already sent to mailhost
See also:
smtp_removemailfromqueue

smtp_sendmail

void smtp_init void   ) 
 

Initializes smtp library.

This function initializes the internal data structures of smtp library. This function should be called first before calling any other functions of smtp library.

NOTE: Other libraries don't need to be initialized before smtp library initialization.

int smtp_removemailfromqueue unsigned long  pmailnode_address  ) 
 

Removes queued mail from mail queue list.

This function removes the mail which was queued by smtp_sendmail.

Parameters:
pmailnode_address - address of mailnode to delete. this value should be same value returned by smtp_sendmail function when queueing mail.
Returns:
SMTP_STATUS_SUCCESS if mailnode was deleted successfully. SMTP_INVALID_MAILNODE_ADDRESS if invalid mail node address is passed or mail has been already sent to mailhost
See also:
smtp_getqueuedmailstatus

smtp_sendmail

int smtp_sendmail struct _mailheader  mail_header,
char *  msg,
char *  attachmentlist[SMTP_MAXATTACHMENTSIZE],
char  queuemail_flag,
unsigned long *  mailnodeaddress
 

Sends mail to mail host.

This function sends mail to mailhost. if smtp host IP address is zero, this function uses dns library to get IP address of target mailhost. if mail host is down and application sets queuemail_flag=1, Mail will be queued to resend later. this function uses base64 MIME encryption for sending attachments. it does not use any encryption for message

Parameters:
mail_header standard mail header object. any uninitialized field name in this structure should be set with NULL value. if default mail header value was initialized and mail_header field value is NULL, the default mail header value will be used.
msg pointer to mail message.
attachmentlist array of string holds attachment filelist. if attachment list is less than SMTP_MAXATTACHMENTSIZE, last element of list should be NULL to indicate end of the list. if there is no attachment to send, then, this argument can be NULL.
queuemail_flag flag to indicate whether mail to be queued or not. if mail host is down and application sets queuemail_flag=1, mail will be queued.
mailnodeaddress address of mail which was queued to resend. this reference value has to be passed to get status of queued mail or to delete it from queue.
Returns:
SMTP_STATUS_SUCCESS if the operation is completed successfully Otherwise, one of the following error values
See also:
smtp_removemailfromqueue

smtp_getqueuedmailstatus

void smtp_setclientsocktimeout long  milli_sec  ) 
 

Sets SMTP client socket timeout value.

This function sets SMTP client socket timeout value. The default SMTP client Time out value after initializing smtp library is 30 seconds.

Warning:
This function is not multi-process safe. If two processes try to call this function at the same time, its parameters may be destroyed, yielding unpredictable results.
Parameters:
milli_sec timeout value in milliseconds

void smtp_setdefaultheadervalue struct _mailheader pmhdr  ) 
 

Sets the default value for standard mail headers.

This function stores address of mail header structure in smtp library global variable. smtp_sendmail function uses pmhdr value by default, user can override these values by passing valid standard mail header value while calling smtp_sendmail function.

NOTE: default mail header value is not mandatory for sending mail. It is optional feature.

Parameters:
pmhdr pointer to the mail header structure
See also:
smtp_sendmail

void smtp_sethostinfo struct _hostinfo phostinfo  ) 
 

Sets the host information object with smtp library.

This function stores address of host configuration information structure in smtp library global variable. Then, configures dns library by setting primary and secondary dns server ip addresses. host configuration information is used to connect with SMTP servers.

Parameters:
phostinfo - pointer to the host information structure
See also:
smtp_sendmail

void smtp_setuserheaderlist struct _userheader pusrhdr  ) 
 

Sets user defined mail header list.

This function stores address of user mail header list structure in smtp library global variable. user defined mail headers will be added while sending mail messages.

NOTE: user mail header list is not mandatory for sending mail. It is optional feature.

Parameters:
pusrhdr pointer to the user mail header list. if user mail header name list is lessthan SMTP_MAXUSERHEADERSIZE,the last item of user mail header namelist should be NULL.
See also:
smtp_sendmail


Copyright 2005 Dallas Semiconductor, Inc.. Documentation generated by Doxygen.