Hi !
I am writing simple email client that uses TCP/IP sockets to interact with an SMTP server to send email messages.
this is my code
import java.io.*;
import java.net.*;
import java.util.*;
import java.text.*;
public class TestSendMail {
public static void main(String args[]) throws IOException {
Socket socket;
DataInputStream dataInput;
DataOutputStream dataOutput;
String mailServer = new String("smtp.gmail.com");
socket = new Socket(mailServer, 587);
dataInput = new DataInputStream( socket.getInputStream());
dataOutput = new DataOutputStream( socket.getOutputStream());
String sender= "mymail@gmail.com";
dataOutput.writeBytes("MAIL FROM: " + sender );
System.out.println( dataInput.readLine() );
String addressee= "friend@gmail.com";
dataOutput.writeBytes("RCPT TO: " + addressee );
System.out.println( dataInput.readLine() );
dataOutput.writeBytes("DATA");
System.out.println( dataInput.readLine() );
dataOutput.writeBytes("This is the first line of testing message.");
dataOutput.writeBytes("This is the second line of testing message.");
dataOutput.writeBytes(".");
System.out.println( dataInput.readLine() );
dataOutput.flush();
socket.close();
}
}
when i am executing it prints only this line and cursor waits....
220 mx.google.com ESMTP x23sm19943471bkw.12
It is not proceeding further.
I dont know why.
Plz help me.