namail_fs: Email Services with File System Example

This example contains basic functionality test on email APIs and allows user to send
authenticated email with a file attachment from the file system.

This example should work on all platforms.

HTTP server and FTP Server are included so that user can download a file into 
the file system.

HTML pages are provided for user to upload a file in to the file system, to start email 
basic functionality test and to send an email with file attachment.

The basic functionality test includes sending an email with a simple test file attachment
which is created during startup, saving email message and any attachment file in the 
file system, and reading email message. This test is run as a separate thread (see
email_test_start() in teststatus_v.c file). 

The mail retrieval test is to get mail listing with headers and retrieve mail message 
with and without saving attachment. This test is in retrTest.c (see test_retr_no_blocking()
and test_retr_blocking()).

User can send an email by accessing the email.htm link. It allows user to specify 
single or multiple recipient's address (use ; to separate each address with space). 
Same as CC address and file attachment. The file attachment must be given in full
path name (i.e. RAM0/DIR0/test.txt). 

The example also demonstrates how authentication can be used to access email. Some
server doesn't allow user to access unless authenticated. The following options
are added in the email configuration page
None:       No authentication
Digest MD5: If server supports Digest MD5 then client will use Digest MD5 to 
            authenticate (requires username and password)
Any:        Client uses one of the following (requires username and password) 
            DIGEST MD5
			CRAM MD5
            LOGIN
            PLAIN 
									  
This "namail_fs" example requires BSP_INCLUDE_FILESYSTEM_FOR_CLIBRARY to be TRUE in bsp_fs.h. Please see BSP. 

This example starts and creates:

1. A test file in \RAM0 (root directory) with group id 1.
2. "DIR0" directory in \RAM0.
3. "DIR1" directory in \RAM0.
6. "user" username & "password" password for accessing all files and web pages.


APP_USE_NETWORK_TIME_PROTOCOL is defined in appconf.h to include time.

APP_FILE_SYSTEM is defined in the build files to include the file system interface for 
the HTTP Server.

All the HTML pages are generated by Page Builder.

To upload a file:

1. Goto the home page by typing the ip address in the URL. 
2. Click on the upload link and a upload page will be displayed.
3. Select a directory where a file will be created.
4. Click the <Browser> button to select a file from the PC
5. Click the <Upload> button to start uploading.

To download or view a file:

1. Type http://ip_address/FS/full_path_filename to retrieve a file.

   The HTTP server uses "FS" to identify a file in the file system.
   HTTP server will prompt username and password entries if a file is not accessible by
   the default group id. 

To start email basic functionality test:

1. Goto the home page by typing the ip address in the URL. 
2. Click on the Mail Services link. 
3. Enter POP3 Address, SMTP address and the port of SMTP.
4. Click "Basic Test" button.
5. Enter username & password for retriving email message.
6. Enter recipient's email address and sender's email address for sending a 
   email with a simple test file.
7. .001 file will be created in RAM0\ directory for retrieving an email message.
8. .txt file will be created in RAM0\ directory for any file attachment when 
   retrieving an email message.
9. mailfile.001 will be created in RAM0\DIR0 directory for retrieving an email message with no attachement saved.

To send an email:

1. Goto the home page by typing the ip address in the URL. 
2. Click on the Mail Services link. 
3. Enter POP3 Address, SMTP address and the port of SMTP.
4. username & password is required for accessing the file attachment
5. Enter recipient's address (use ; for multiple address without any space).
6. Enter cc address (user ; for multiple address without any space).
7. Enter sender's address 
8. Enter subject
9. Enter file name (use ; for mutliple file without any space). Files must be
   uploaded in the file system. 
10. Type body message.
11. Click <Send> button. It will start sending the email.  

To retrieve email test:

1. Goto the home page by typing the ip address in the URL. 
2. Click on the Login Mail Client Test link. 
3. Enter POP3 Address.
4. username & password is required to login the mail server.
5. Enter number of messages for mail listing
7. Enter sender's address which the mail messaage will be removed. 
10. Select WAIT or NO WAIT option. test_retr_blocking() is going to run for WAIT option
    and test_retr_no_blocking() is going to run for NO WAIT option. 
11. Click <Start> button. It will start the test.  

One GNU make file is provided.  Build the target 'image' to
generate an image that can be debugged with gdb, and the file 
image.bin which can be written to flash if the bootloader is used.
Build the target 'rom.bin' to create the file rom.bin which 
can be written to ROM if the bootloader is not used.

The following files are provided with this example:

appconf.h         sets application configuration settings
makefile          Make file for the GNU toolset.
readme            this file

root.c            			contains applicationStart() function
naftpapp.c		  			contains function to setup and start FTP server
security.c					Setup access realm for username & password
pbuilder\RpUsrDct.c   		Phrases used in html pages that HTTP server needs.
pbuilder\RpPages.c	  		Contains links of all html pages. 
pbuilder\html\index.c 		Home page generated.
pbuilder\index_v.c			Contains functions for index.c
pbuilder\html\upload.c		HTML page to upload a file
pbuilder\upload_v.c			Contains functions for upload.c
pbuilder\html\delete.c		HTML page to empty a directory
pbuilder\delete_v.c			Contains functions for delete.c
pbuilder\html\groupid.c		HTML page to set default group id for HTTP server
pbuilder\groupid_v.c		Contains functions for groupid.c
pbuilder\html\filelist.c	HTML page to display a list of files in the file system.
pbuilder\filelist_v.c 		Contains functions for filelist.c
pbuilder\html\statusmsg.c	Status message HTML page
pbuilder\statusmsg_v.c		Contains functions for statusmsg.c
pbuilder\html\sendmail.c   	HTML page to send email message
pbuilder\sendmail_v.c		Contains functions for sendmail.c
pbuilder\html\emailtest.c	HTML page to setup email basic functionality test
pbuilder\emailtest_v.c		Contains functions for emailtest.c
pbuilder\html\teststatus.c	HTML page to start email basic functionality test
pbuilder\teststatus_v.c		Contains functions for teststartus.c
pbuilder\html\email.c		HTML page to setup email server 
pbuilder\email_v.c			Contains functions for email.c
pbuilder\html\emailstatus.c	HTML page to display email status
pbuilder\emailstatus_v.c	Contains functions for emailstatus.c
..\..\..\src\rphttpd\cgi.c	User defined CGI support
..\..\..\src\rphttpd\file.c Contains interface between the file system and HTTP server.
..\..\..\src\fs_intf\ftpsvrfs.c	Contains interface between the file system and FTP server.
..\..\..\src\fs_intf\mailfile.c	Contains interface between the file system and email services.



In addition, the following files in the BSP directory are built as part of this 
example:

reset.s         contains the reset code
appconf_api.c   contains code used to read settings in appconf.h


The build file links in the following libraries:

libbsp.a           		contains the BSP code
libtcpip.a         		contains the Net+Works TCP/IP stack
libtx.a            		contains the ThreadX kernel
libfilesys.a       		contains the file system libraries
libposix.a         		contains the POSIX layer libraries
libflash.a         		contains the Flash driver API library
libftpsvr.a        		contains the FTP server library
libemailc.a        		contains the Email client library
libtelnsvr.a       		contains the Telnet server library
libaddp.a		   		contains the ADDP Library
libssh.a		   		contains the SSH Library
librphttpd.a       		contains the NET+Works AWS API library.
libmanapi.a        		contains the NET+Works Management API library.
libpppintf.a			contains the PPP Interface Library
libdnsclnt.a        	contains the DNS Client library

The application uses the following files located in the
netos\src\linkerScripts directory.

bootldr.dat     bootloader configuration file used to generate the
                file image.bin.  It controls the information placed
                in the bootloader header of the image.

image.ldr       GNU linker script used to build an image that can
                be debugged and used with the bootloader.
                
customize.ldr   Customizable GNU linker script


