// package pic20b;

import java.io.*;
import java.net.*;

public class Email {
    public static void main(String[] args) throws IOException {
	Socket sock;
	BufferedReader sockIn;
	PrintStream sockOut;

	sock = new Socket("smtp.ucla.edu", 25);
	sockIn = new BufferedReader(
		new InputStreamReader(sock.getInputStream()));
	sockOut = new PrintStream(sock.getOutputStream());

	sockOut.println("helo ucla.edu");

	String sender = "bob@ucla.edu";
	sockOut.println("mail from: " + sender);
	System.out.println(sockIn.readLine());

	String addressee = "fedandr@math.ucla.edu";
	sockOut.println("rcpt to: " + addressee);
	System.out.println(sockIn.readLine());

	sockOut.println("data");
	System.out.println(sockIn.readLine());

	sockOut.println("This is the message\n that Java sent");
	sockOut.println(".");
	System.out.println(sockIn.readLine());

	sockOut.flush();
	sock.close();

    }
}
