The requirement and target of the project should be introduced.
The target of the project is to develop a POP3 client.
- Receive Email from pop3 server (pop.163.com) and store it as *.eml file.
- Friendly User Interface and good interactive User Experience (no GUI required). Requirements:
The requirement of the project is analyzed here, including,
- Development Environment, such as OS and programming language
- Functional requirements in details, including task decomposition and analysis
Development environment: Linux OS with “gcc” complier using C language.
Functional requirements:
Construct a socket which domain name is pop.163.com and port number is 110. Using “connect” to connect the pop3 server. Using “select” to listen the socket buffer, and then use FD_ZERO, FD_SET, FD_ISSET operation to achieve write user input to socket buffer or read server message from the socket buffer and use “send” and “recv” to send message to server and receive message from server.
Read user input username and use strcat() to construct the “USER” message send to server. Read user input password and use strcat() to construct the “PASS” message send to server. After successfully login, user can send “LIST” and “STAT” message to server to check information about their emails.
Send “RETR” message, and sleep 1s before using recv() to receive server feedback in order to receive all the content in one time. Then use printf() to display the buffer content. Using “strstr()” to find the content plain text encode in base64, and then use base64_decode function to display the content in ASCII.
Using “$sudo wireshark” command to open wirshark process and in the wireshark interface set the recrive filter as “tcp port 110”. And then can captured POP packet from server.
Using “termio.h” to replace user input password as *.
Using “fopen()” to open an local file and write the recv content from server to the file. Then send “DELE” to server to delete the corresponding mail.
Using “strstr()” to find the Begin and End pointer for the subject and print it into terminal. Using for to check each mail by sequence.
Using for to check whether user input is in the email by comparing each char. Using for to check each mail by sequence.
Detailed design includes
- Design analysis of each module
- Flow chart of each module
Design analysis of each module:
Construct a socket using tcp which domain name is pop.163.com and port number is 110. Using “connect” to connect the pop3 server. Using “select” to listen the socket buffer, and then use FD_ZERO, FD_SET, FD_ISSET operation to achieve write user input to socket buffer or read server message from the socket buffer and use “send” and “recv” to send message to server and receive message from server.
Read user input username and use strcat() to construct the “USER” message then send to server. Read user input password and use strcat() to construct the “PASS” message then send to server.
After successfully login, user can send “LIST” and “STAT” message to server to check information about their emails.
Send “RETR” message, and sleep 1s before using recv() to receive server feedback in order to receive all the content in one time. Then use printf() to display the buffer content. Using “strstr()” to find the content plain text encode in base64, and then use base64_decode function to display the content in ASCII.
Using for to check whether user input is in the email by comparing each char. Using for to check each mail by sequence.
Using “strstr()” to find the Begin and End pointer for the subject and print it into terminal. Using for to check each mail by sequence.
Can download mails and save them only on local machine (remove from remote server): Using “fopen()” to open an local file and write the recv content from server to the file. Then send “DELE” to server to delete the corresponding mail.