Professional Documents
Culture Documents
E MAIL SYSTEM
MINOR PROJECT 2004
INFORMATION TECHNOLOGY VI Semester Guided By Submitted By
CERTIFICATE
This is to certify that this project report entitled E MAIL SYSTEM Has been prepared by Neeti Bagani And Saba Karimi students of III year I.T. The system has been approved by the Department of Information Technology, Shri Vaishnav Institute of Technology and Science, Indore (M.P.) and the work has been done under our guidance. This work is up to the mark of satisfaction. We wish them success in every aspect of life. They have performed this project on their own. They have also put in sufficient time for completion. This project has been completed as per rules of R.G.P.V Syllabus for Minor Project VI semester. Date: Place: Indore
ACKNOWLEDGMENT
We feel immense pleasure and deep feeling of gratitude towards Ms. Sunita Verma and Mr. Anand Rajawat of Shri Vaishnav Institute of Technology and Science, Indore for their skillful guidance, constructive and valuable suggestion and encouraging co-operation for our project, which not merely helped but enable us to give effort towards this project. We also extend our thanks to all our colleagues and friends for their valuable assistance and kind co-operation during the course of this investigation.
CONTENTS
S NO
1 2 Abstract Introduction i Definition of Project ii Technical details of Project iii Need of Project 3 Analysis i Hardware Requirements ii Software Requirements iii Other Requirements 4 5 Feasibility Design i Algorithm ii Data Flow Diagram 6 8 9 10 Instructions for using the Project Conclusion Bibliography Annexure 8 10 14 15 16 17 6 6 6 7 2 3 5
TOPIC
PAGE NO
1
ABSTRACT
Email has become one of the driving forces behind connecting businesses to the Internet. It offers fast, economical transfer of messages. The substantial cost cutting by using an email system has encouraged many businesses to invest in an implementation of email systems. The email server is an application to facilitate sending and receiving of emails. Our project works towards implementing the socket programming and providing the user with multithreading to enable servicing of various clients simultaneously. This project is a basic client server model and it can be extended to implement SMTP and POP3 protocols.
In the above example, the three workstations are connected to a computer network within a company office. If one user wishes to send email to another user, then the message is simply typed and sent to the mail server, addressed to the recipient using their email name, which would simply be the first name of a user, such as "Neeti". For example: if Saba wants to send a message to Neeti, she types her message on her email client, addressing it to Neeti. Her email client then sends the message to the mail server (via SMTP protocol), where it is stored for Neeti. When Neeti next checks to see if there is any mail for her, her
7
email client will collect her messages (using POP3 protocol) and allow her to read them. Because this email system works only within the office, each recipient can be referred to using only his or her email name. This system could easily be expanded to allow for remote users if some form of dial in support is added to the network using a modem (A modem is a device that sends computer signals down a telephone line, effectively making a telephone system a part of a computer network). This would increase the flexibility of the system enormously.
Software Requirements
Windows 9X/XP/NT OS JDK 1.4 Java Editor RDBMS Oracle 8I
10
Technical Feasibility
Resource Availability:
Are the hardware and software resources required available to develop the application?
Technology:
Do the system designers have the skills and guidance to achieve their goal?
Legal Feasibility
11
A development of any infringement, violation or liability that could result from development of the system violates legal feasibility. There is no such law or rule, which will be violated by the development of this software.
DESIGN Algorithm
Connection Establishment:
1 Get a port number from the user or use default. 2 Create a server socket on that port number. 3 Wait indefinitely for an attempt by a client to connect. 4 Bind the client with the server port after accepting it. 5 Get output and input stream objects that enable the server to communicate with the clients. 6 Communicate with the client. 7 Terminate connection when transmission is complete.
Login:
1 Enter the E-mail ID if there is already one assigned or else select the new user option. 2 The new user option allows the user to get a new E-mail ID. 3 The password check for authenticity checks the password from the database.
12
4 In case of forgetting password there is the option for hint question submitted at the time of creating the ID.
Inbox:
1 There is a complete record of all the e-mails received and you can select any one for viewing or can delete any e-mail. 2 The compose option allows the user to write mail or attach files to be sent to other users. 3 There is also the facility for word processing, word completion and stationery for easy and better composing. 4 After completion of work the user can log out from his account, thereby terminating the connection.
13
E-Mail Server
Message to User 2
14
Level 1 DFD:
New User
Entry Form
Connection
Connection Established
Existing User
Logi n
Logout
Compos e
Inbox
Connection Terminated
Delet e
Stationer y
Word Processing
Send
15 Mails
Level 2 DFD:
Connection Establishment:
Administrator
User
16
Login:
Existing User
Login
Connection Established
New User
Registered User
17
18
CODING
The two important modules in our project are: Client
import import import import java.io.*; java.net.Socket; java.net.UnknownHostException; java.util.LinkedList;
public class Client { public Client() { } public static void main(String args[]) { int i = 2222; String s = "localhost"; if(args.length < 2) { System.out.println("Usage: java User \nNow using host=" + s + ", port_number=" + i); } else { s = args[0]; i = Integer.valueOf(args[1]).intValue(); } try { clientsocket = new Socket(s, i); oos = new ObjectOutputStream(clientsocket.getOutputStream()); ois = new ObjectInputStream(clientsocket.getInputStream()); 19
} catch(UnknownHostException _ex) { System.out.println("Don't know about host " + s); } catch(EOFException _ex) { System.out.println("server terminated connection"); } catch(IOException ioexception) { System.err.println("Couldn't get I/O for the connection to the host " + s); ioexception.printStackTrace(); } try { Login login = new Login(); Object obj = null; while(login.objectlogin.loginname == null && login.objectlogin.password == null && login.objectnewuser.loginname == null && login.objectnewuser.password == null && login.objectnewuser.retype == null && login.objectnewuser.index == 0 && login.objectnewuser.answer == null) ; oos.writeObject(login.objectlogin); if(login.objectnewuser.loginname != null || login.objectnewuser.password != null || login.objectnewuser.retype != null || login.objectnewuser.index != 0 || login.objectnewuser.answer != null) { oos.writeObject("1"); oos.writeObject(login.objectnewuser); while(login.objectlogin.loginname == null && login.objectlogin.password == null) ; } else { boolean flag = login.objectlogin.loginname == null && login.objectlogin.password == null; oos.writeObject("2"); System.out.println("Sucessfull"); } Integer integer = (Integer)ois.readObject(); System.out.println("integer object recieved"); int j = integer.intValue(); System.out.println("i=" + j); LinkedList linkedlist = (LinkedList)ois.readObject(); 20
System.out.println("after recieving linklist"); Inbox inbox; for(inbox = new Inbox(linkedlist); inbox.objectcompose.to == null && inbox.objectcompose.from == null && inbox.objectcompose.subject == null && inbox.objectcompose.data == null;); System.out.println("After 2 while"); System.out.println(inbox.objectcompose.to); System.out.println(inbox.objectcompose.from); System.out.println(inbox.objectcompose.subject); System.out.println(inbox.objectcompose.data); oos.writeObject(inbox.objectcompose); System.out.println("client send inbox object"); oos.flush(); oos.close(); } catch(Exception exception) { System.out.println(exception); } } static Socket clientsocket = null; static ObjectOutputStream oos = null; static ObjectInputStream ois = null; }
Server
import java.io.*; import java.net.*; import java .sql.*; import java.util.*; public class Server1 { static Socket clientsocket = null; static ServerSocket serversocket = null;
21
static ObjectOutputStream oos=null; static ObjectInputStream ois=null; public static Connection connection; public static Statement statement; public static ResultSet resultset; public static void main(String args[]) { int port_number=2222; if (args.length < 1) { System.out.println("Usage: java MultiThreadChatServer \n"+ "Now using port number="+port_number); } else { port_number=Integer.valueOf(args[0]).intValue(); } try { serversocket = new ServerSocket(port_number); clientsocket = serversocket.accept(); oos=new ObjectOutputStream(clientsocket.getOutputStream()); ois=new ObjectInputStream(clientsocket.getInputStream()); } catch (IOException e) { System.out.println(e); } 22
catch(Exception e) { System.out.println(e); } //The url is specifing the database to which this program //connects using jdbc to connect to a microsoft odbc database String url="jdbc:odbc:email"; //try to load the driver to allow connection to the server_database try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); connection=DriverManager.getConnection(url); } catch(ClassNotFoundException cnfex) { System.err.println("failed to load jdbc/odbc driver"); cnfex.printStackTrace(); System.exit(1); }//terminate programe catch(SQLException sqlex) { System.err.println("Unable To Connect"); sqlex.printStackTrace(); } try { 23
statement=connection.createStatement(); String query=null; String query1=null; int i=0; String name=null; String str,sender,subject,data; String msg="i have recieved your object"; ObjectNew objectnewuser; ObjectLogin objectlogin; objectlogin=(ObjectLogin)ois.readObject(); str=(String)ois.readObject(); LinkedList list=new LinkedList(); ObjectInbox inbox[]=new ObjectInbox[10]; if(str.equals("1")) { objectnewuser=(ObjectNew)ois.readObject(); query="insert into email_table (loginname,password,index,answer) values('"+objectnewuser.loginname +"','"+objectnewuser.password+"','"+objectnewuser.index+"','"+objec tnewuser.answer+"')"; int result=statement.executeUpdate(query); if(result== 1) System.out.println("Insertion successful"); else System.out.println("Insertion unsuccessful"); str="2"; }
24
System.out.println(objectlogin.loginname); System.out.println(objectlogin.password); query="SELECT * FROM email_table "+"WHERE loginname='"+objectlogin.loginname+"'"; name=objectlogin.loginname; System.out.println("after query"); resultset=statement.executeQuery(query); boolean more=resultset.next(); System.out.println("boolean="+more); while(more){ System.out.println("in while"); i=i+1; more=resultset.next(); } System.out.println("after recordnumber"); if(i==0) System.out.println("no record found"); else System.out.println("recordnumber="+i); Integer integer=new Integer(i); oos.writeObject(integer); System.out.println("integer Object send"); System.out.println("name" +name); query1="SELECT * FROM email_compose "+"WHERE reciever='"+name+"'"; resultset=statement.executeQuery(query1); more=resultset.next(); System.out.println("boolean="+more); 25
while(more){ System.out.println("in 2 while"); sender=resultset.getString(2); subject=resultset.getString(4); data=resultset.getString(5); System.out.println("sender="+sender); System.out.println("subject="+subject); System.out.println("data="+data); inbox[i]=new ObjectInbox(sender,subject,data); list.add(inbox[i]); more=resultset.next(); } oos.writeObject(list); System.out.println("after sending linklist"); ObjectCompose objectcompose=new ObjectCompose("we"); ObjectLogin object3=new ObjectLogin("we"); objectcompose=(ObjectCompose)ois.readObject(); System.out.println("Server accept inbox objectcompose"); query="insert into email_compose (sender,reciever,subject,data) values('"+objectcompose.from +"','"+objectcompose.to+"','"+objectcompose.subject+"','"+objectco mpose.data+"')"; int result=statement.executeUpdate(query); System.out.println(result); System.out.println("statement executed"); if(result==1) 26
System.out.println("Insertion successfull"); else System.out.println("Insertion unsuccessfull"); /*if(str.equals("2")) { object3=(ObjectLogin)ois.readObject(); System.out.println(object3.loginname); System.out.println(object3.password); query="SELECT * FROM email_table "+"WHERE loginname='"+object3.loginname+"'"; System.out.println("after query"); resultset=statement.executeQuery(query); System.out.println("after resultset"); System.out.println(objectcompose.to); System.out.println(objectcompose.from); System.out.println(objectcompose.subject); System.out.println(objectcompose.data);*/ ois.close(); connection.close(); statement.close(); //} }catch(SQLException sql) { System.out.println("connection does'nt create statement"); sql.printStackTrace(); System.out.println(sql.toString()); } catch(Exception e){ System.out.println(e+"nsit"); } } 27
CONCLUSION
The limitations of our project are: 1. It works only on a LAN. 2. The front end is not very user friendly. 3. The mails are not getting deleted from the inbox. 4. Attachment and Forwarding facilities are not provided. 5. The mail can be only limited to a fixed, predefined length. There were various difficulties encountered in our project which are as follows: 1. It was not clear when to use which class and when to make our own classes as we used core JAVA. 2. The compatibility between the various JAVA editors (JBuilder and Gel) was not proper. There are various suggestions that we would like to give for the future enhancement of this project: 1. Making the front end more user friendly. 2. Implementing it for the use on the Internet and not only LAN.
28
BIBLIOGRAPHY
1. Core JAVA volumes 1 and 2 - Sun Microsystems 2. JAVA How to Program - Deitel and Deitel 3. JAVA the complete reference - Herbert Schildt
29
30
constraint faced by laboratory structure in the developing world was availability of limited funds. Many of the problems while setting the laboratory were though not experienced in developed nations, thereby making it more valuable to those in the developing world who are contemplating setting up experimental facilities for teaching networking.
31