我需要帮助来创建上述内容:在两端 SMTP 之间安全传输电子邮件。我必须创建 SMTP 客户端 SMTP 服务器以及证书与需要它的各种实体的因果关系。然后我需要从另一端的文件 xxxxxx.txt 发送数据。
我从这个代码开始创建 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){}
}
}