I’m kinda interested in with java sockets in these days and i want to read my mails from gmail with using java socket. is it possible?
Socket s;
s = new Socket("imap.gmail.com", 993);
InputStream in;
in = s.getInputStream();
BufferedReader sin = new BufferedReader(new InputStreamReader(in));
PrintWriter output = new PrintWriter(new OutputStreamWriter(s.getOutputStream()));
String line;
output.println("a001 LOGIN my-e-mail my-pass");
output.flush();
while ((line = sin.readLine()) != null)
System.out.println(line);
s.close();
what should i do after connecting to socket?
thanks in advance. (notice: i dont want to use java mail api, things get really easy with it, i’m just choosing this way to get familiar what’s going on behind the scene)
edited the code.
Once you have a socket you implement the IMAP protocol on it.
https://www.rfc-editor.org/rfc/rfc3501