import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.net.*;
import java.sql.*;
import java.util.*;

public class littleMailer {
     
    public littleMailer() {
    }

    public static void main(String[] args){


        try {
            SMTP_mailer SMTP_server=new SMTP_mailer();
            String from_who="siegel@hoare.cs.umsl.edu";
            String to_who="siegel@arch.umsl.edu";
            SMTP_server.sendMail(from_who,to_who);        
        } catch (Exception e) {
            return;
        }
    } 

}
class SMTP_mailer {

    public boolean sendMail(String from_address,String to_address ){
        String SMTP_SERVER="arch.umsl.edu";
        String testing="just testing";
        String print_it;
        try {
            Socket sock=new Socket(SMTP_SERVER, 25);
            BufferedReader inStream=new BufferedReader(new InputStreamReader(sock.getInputStream()));
            PrintWriter outStream=new PrintWriter(sock.getOutputStream()); 
            System.out.println(print_it=inStream.readLine());
            if (!(print_it.substring(0,3).equals("220"))) {
                sock.close(); return false;
            }
            outStream.println ("HELO hoare.cs.umsl.edu");
            outStream.flush();
            System.out.println(print_it=inStream.readLine());
            if (!(print_it.substring(0,3).equals("250"))) {
                sock.close(); return false;
            }
            outStream.println("MAIL FROM: "+ from_address);
            outStream.flush();
            System.out.println(print_it=inStream.readLine());
            if (!(print_it.substring(0,3).equals("250"))) {
                sock.close(); return false;
            }
            outStream.println("RCPT TO: " + to_address);
            outStream.flush();
            System.out.println(print_it=inStream.readLine());
            if (!(print_it.substring(0,3).equals("250"))) {
                sock.close(); return false;
            }
            outStream.println("DATA");
            outStream.println("Subject: "+testing);
            outStream.flush();
            System.out.println(print_it=inStream.readLine());
            if (!(print_it.substring(0,3).equals("354"))) {
                sock.close(); return false;
            }
            outStream.println("a message");
            outStream.println(".");
            outStream.flush();
            System.out.println(print_it=inStream.readLine());
            if (!(print_it.substring(0,3).equals("250"))) {
                sock.close(); return false;
            }
            outStream.println("QUIT");
            outStream.flush();
            System.out.println(print_it=inStream.readLine());
            if (!(print_it.substring(0,3).equals("221"))) {
                sock.close(); return false;
            }
            sock.close();
        } catch (UnknownHostException e) {
            System.out.println("UnknownHost");
            return false;
        } catch (IOException e) {
            e.printStackTrace(); 
            return false;
        }
        return true;
    }

    void refresh(){}

}


The Dialog

220 arch.cs.umsl.edu ESMTP Sendmail 8.14.4/8.14.4; Tue, 8 Sep 2015 08:51:18 -0500
250 arch.cs.umsl.edu Hello hoare.cs.umsl.edu [134.124.30.128], pleased to meet you
250 2.1.0 siegel@hoare.cs.umsl.edu... Sender ok
250 2.1.5 siegel@arch.umsl.edu... Recipient ok
354 Enter mail, end with "." on a line by itself
250 2.0.0 t88ECZrX011234 Message accepted for delivery
221 2.0.0 arch.cs.umsl.edu closing connection

The email