Solutions for Mail User Agent: Simplified Version
import java.io.*;
import java.net.*;
public class EmailSender
{
public static void main(String[] args) throws Exception
{
throw new Exception(“220 reply not received from server.”);
}
// Get a reference to the socket’s output stream.
OutputStream os = socket.getOutputStream();
// Send HELO command and get server response.
String command = “HELO x\r\n”;
response = br.readLine();
System.out.println(response);
if (!response.startsWith(“250”)) {
throw new Exception(“250 reply not received from server.”);
}
// Send RCPT TO command.
}
os.write(command.getBytes(“USASCII”));
response = br.readLine();
System.out.println(response);
if (!response.startsWith(“354”)) {
throw new Exception(“354 reply not received from server.”);
}
throw new Exception(“250 reply not received from server.”);
}
// Send QUIT command.
command = “QUIT\r\n”;
System.out.print(command);
os.write(command.getBytes(“USASCII”));
}
}