import java.io.*; import java.net.*; public class email { public static void main(String args[]) throws IOException { Socket sock = null; BufferedReader bis = null; PrintStream ps = null; try { sock = new Socket("localhost", 25); bis = new BufferedReader( new InputStreamReader(sock.getInputStream())); ps = new PrintStream(sock.getOutputStream()); ps.println("mail from: trelford"); //System.out.println( dis.readLine() ); // Exercise for student: // check all responses from the SMTP server // They should all start with "2nn" or "3nn" // Any different reply code means a failure to send mail. System.out.println(bis.readLine()); } catch (IOException ioe) { System.out.println("Sorry, your system is not running a mailserver on port 25"); System.exit(0); } String Addressee= "linden"; ps.println("rcpt to: " + Addressee); //System.out.println( dis.readLine() ); System.out.println(bis.readLine()); ps.println("data"); //System.out.println( dis.readLine() ); System.out.println(bis.readLine()); ps.println("This is the message\n that Java sent"); ps.println("."); System.out.println(bis.readLine()); ps.flush(); sock.close(); } }