Networking Java Solutions Homework Open an SMTP connection to a remote machine and

subject Type Homework Help
subject Pages 2
subject Words 415
subject Authors James F. Kurose, Keith W. Ross

Unlock document.

This document is partially blurred.
Unlock all pages and 1 million more documents.
Get Access
page-pf1
Solution for the Mail Client Lab
SMTPConnection.java
import java.net.*;
import java.io.*;
import java.util.*;
/* $Id: SMTPConnection.java,v 1.1.1.1 2003/09/30 14:36:01 kangasha Exp $ */
/**
* Open an SMTP connection to a remote machine and send one mail.
*
* @author Jussi Kangasharju
*/
public class SMTPConnection {
/* The socket to the server */
public Socket connection;
/* Streams for reading and writing the socket */
public BufferedReader fromServer;
public DataOutputStream toServer;
/* Just to make it look nicer */
private static final int SMTP_PORT = 25;
private static final String CRLF = "\r\n";
/* Are we connected? Used in close() to determine what to do. */
page-pf2
}
isConnected = true;
}
/* Close the connection. Try to send QUIT-commmand and then close
the socket. */
public void close() {
isConnected = false;
try {
sendCommand("QUIT", 221);
connection.close();
} catch (IOException e) {
System.out.println("Unable to close connection: " + e);
isConnected = true;
}
}
/* Send an SMTP command to the server. Check for reply code. Does
not check for multiple reply codes (required for RCPT TO). */
private void sendCommand(String command, int rc) throws IOException {
String reply = null;
}

Trusted by Thousands of
Students

Here are what students say about us.

Copyright ©2022 All rights reserved. | CoursePaper is not sponsored or endorsed by any college or university.