1
我需要幫助來創建上述內容: 兩端之間安全傳輸電子郵件SMTP.I必須創建 SMTP客戶端SMTP服務器和因果關係證書給 需要它的各種實體。然後我需要從另一邊的文件xxxxxx.txt發送數據。使用ssl證書創建SMTP客戶端和SMTP服務器(在oepnssl上創建)
我從這段代碼開始創建SMTP客戶端和服務器,我不確定這是否是正確的代碼。 (我需要使用NetBeans) - (我也創建與OpenSSL的證書)
// Client_Sock.java代碼
package client_sock;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;
package client_sock;
public class Client_Sock {
public static void main(String[] args) {
try
{
Socket sock =new Socket ("locakhost",9999);
PrintStream pr = new PrintStream(sock.getOutputStream());
system.out.print("Ergasia 01 pes 620 20013:");
InputStreamReader rd = new InputStreamReader (System.in);
BufferedReader ed = new Bufferedreader(rd);
String temp = ed.readLine();
pr.println(temp);
BufferedReader gt = new BufferedReader(new InputStreamReader(sock.getInputStream()));
String tm = gt.readLine();
System.out.print(tm);
}
catch (Exception ex)
{
}
}
}
//Server_Sock.java代碼
package server_sock;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;
public class Server_Sock {
public static void main(String[] args) {
try
{
ServerSocket ser = new ServerSocket (9999);
Socket sock = ser.accept();
BufferedReader ed =new BufferedReader (new InputStreamReader(sock.getInputsStream()));
String tmp = ed.readLine();
System.out.print("Irecieved:"+tmp);
PrintStream pr = new PrintStream(sock.getOutputStream());
String str = "The message delivered succesfully !!"
pr.println(str);
}
catch(Exception ex){}
}
}
感謝您的回覆, – xarismy
我很有趣第二個選項,但我可以繼續這個代碼或創建一個新的?當你談論SMTP包你的意思是「smtp.pop3,e.t.c」? – xarismy
我的意思是這樣的:https://www.google.co.uk/search?q=Java+smtp –