生活随笔
收集整理的這篇文章主要介紹了
基于JavaWeb的网页版邮箱系统设计与实现
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
資源下載地址:https://download.csdn.net/download/sheziqiong/86790177
資源下載地址:https://download.csdn.net/download/sheziqiong/86790177
目錄
一、 項目選題 2
程序功能: 2
二、 開發(fā)環(huán)境和工具 2
三、 項目使用說明手冊 2
四、 系統(tǒng)結構 2
項目目錄結構 2系統(tǒng)執(zhí)行過程 3
五、 系統(tǒng)內核心實現(xiàn) 4模塊動態(tài)加載 4對webpage下的服務進行掃描 4通過retr命令獲取郵件,并且通過json格式返回到web前端 5配置文件的讀取 6
六、 項目運行截圖 7首頁 7郵箱郵件查詢 7郵件發(fā)送 8郵件詳情 9配置文件設置 9Web服務器錯誤頁 10Web服務器主頁 10兩個不同的郵箱進行測試 11
一、項目選題
基于實現(xiàn)的一個Web服務器的網頁版郵箱客戶端系統(tǒng)
項目中的服務器為自己實現(xiàn)的Web服務器,對http訪問進行響應
項目中的郵箱客戶端是基于socket進行smtp和pop3郵箱連接的客戶端實現(xiàn)
該項目將Web服務器和郵件客戶端兩個項目選題相結合
程序功能:
1.Web服務器功能對響應的HTTP資源的請求和對于郵件api的訪問給予響應
2.郵件能夠實現(xiàn)查詢郵件,本文轉載自http://www.biyezuopin.vip/onews.asp?id=15154查看郵件詳細信息,刪除郵件,發(fā)送郵件,郵件返回分頁等功能
3.此項目在163郵箱和qq郵箱測試成功
二、開發(fā)環(huán)境和工具
系統(tǒng)環(huán)境 Windows10 1903
開發(fā)工具 Intellij Idea Ultimate 2019、WebStorm、Chrome
jdk版本 12.0.2(如果在jdk1.8的情況下報錯,請按照錯誤修改)
三、項目使用說明手冊
1.使用idea加載并打開工程
2.在serverConfig.properties文件中進行相關的配置文件的配置
3.瀏覽器輸入http://127.0.0.1:8080/index.html進入主頁面(如果未修改配置文件信息),輸入不存在的資源目錄則進入錯誤頁面
4.瀏覽器輸入http://127.0.0.1:8080/mailAgentWeb/index.html進入郵箱客戶端web主頁面
5.在該頁面可以實現(xiàn)郵件查詢、郵件刪除、郵件詳細信息查看等功能,切換tab可以使用郵件發(fā)送功能 。
import net.sf.json.JSONObject;import java.io.*;
import java.net.Socket;
import java.util.HashMap;
import java.util.List;
import java.util.Map;public class MailAgentThread extends WebService {private InputStream in = null;private OutputStream out = null;private Map<String, String> params = null;//用來保存對應的smtp的地址和對應的認證信息等private Map<String, List<String>> serverAddressInfo = null;//賬號:2403116996//授權碼:xevyrfcqimxfdhiaMailAgentThread(Socket socket) {try {this.in = socket.getInputStream();this.out = socket.getOutputStream();this.params = new HashMap<>();} catch (IOException e) {e.printStackTrace();}}@Overridepublic void run() {boolean state = false;String apiInfo = readApiInfo(this.in);params.clear();if (!apiInfo.contains("?")) {System.out.println("[萬惡之原]mailAgentService請求中未帶有參數(shù)!");reportError();return;}for (String item : apiInfo.split("\\?")[1].split("&")) {params.put(item.split("=")[0], item.split("=")[1]);}String serverName = params.get("username").split("@")[1];params.put("username", params.get("username").split("@")[0]);MailAgent mailAgent = new MailAgent("smtp." + serverName);state = mailAgent.login(params.get("username"), params.get("password"));if (!state) {System.out.println("[mailAgentService]服務中賬號密碼登陸失敗!");reportError();return;}if (!params.containsKey("type")) {reportError();return;}if (params.get("type").equals("send")) {state = mailAgent.sendMail(params);if (state) {String result = "HTTP/1.1 200 ok \n" +"Content-Type: text/html \n" +"Access-Control-Allow-Origin: *\n";try {this.out.write(result.getBytes());out.flush();out.close();} catch (IOException e) {e.printStackTrace();}}} else if (params.get("type").equals("query")) {//todo:這里是查詢郵件的業(yè)務邏輯String mailJson = mailAgent.queryMail(params);String result = "HTTP/1.1 200 ok \n" +"Content-Type: application/json;charset=UTF-8 \n" +"Access-Control-Allow-Origin: *\n" +"\n" + mailJson;try {out.write(result.getBytes());out.flush();out.close();} catch (IOException e) {e.printStackTrace();}}else if (params.get("type").equals("delete")){JSONObject json = new JSONObject();state = mailAgent.deleteMail(params);json.put("deleteState",state);String result = "HTTP/1.1 200 ok \n" +"Content-Type: application/json;charset=UTF-8 \n" +"Access-Control-Allow-Origin: *\n" +"\n" + json.toString();try {out.write(result.getBytes());out.flush();out.close();} catch (IOException e) {e.printStackTrace();}}}private void reportError() {String result = "HTTP/1.1 400 ok \n" +"Content-Type: text/html \n" +"Access-Control-Allow-Origin: *\n";try {this.out.write(result.getBytes());out.flush();out.close();} catch (IOException e) {e.printStackTrace();}}
}
資源下載地址:https://download.csdn.net/download/sheziqiong/86790177
資源下載地址:https://download.csdn.net/download/sheziqiong/86790177
總結
以上是生活随笔為你收集整理的基于JavaWeb的网页版邮箱系统设计与实现的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。