Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6678021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:11:37+00:00 2026-05-26T04:11:37+00:00

I am trying to write a simple mail client in Java with sockets. But

  • 0

I am trying to write a simple mail client in Java with sockets. But I am thinking what is the best way to handle the response from the server? Suppose I have a simple code like the one below:

smtpSock = new Socket(mailHost, SMTP_PORT);
inn = smtpSock.getInputStream();
outt = smtpSock.getOutputStream();
in = new BufferedReader(new InputStreamReader(inn));
out = new PrintWriter(new OutputStreamWriter(outt), true);

out.println("AUTH LOGIN " + user.getID());
String response = in.readLine();
//manipulate the response string to check if user ID exists on server
//if ID exists, proceed to password. Else, quit.

out.println("PASS " + user.getPassword());
response = in.readLine();
//manipulate the response string to check if auth success or not

After I have issued the AUTH LOGIN commmand and given the user ID as the parameter, the server is likely going to give a response. I can get the response to a String. Now, to understand the response and know what to do next, I am thinking that I would manipulate the string by tokenising it and then read the first 3 characters one by one to interpret the response code number. This may sound ok since the response code is only 3 characters.

But then what happens if say the socket is now connecting to a POP3 and is retrieving mails. The response is going to be pretty huge. Is there a good and not too complex method to interpret the response and then put them into a data structure? If parsing the string is the only way, would my idea of tokenising the huge set of String data according to its “textual patterns” a little too naive? Is there a more efficient and faster way of doing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:11:37+00:00Added an answer on May 26, 2026 at 4:11 am

    POP3 is very different than SMTP, among others it uses different response syntax. SMTP has three letter codes, yes, but I would add that there could be extended status codes too following the simple code. POP3 does not have error codes, only a common negative message. You can parse line by line both of them. POP3 does not preceede each line of the message with a status code of course. If the message is very large then you have to write it into a file while you reveive it. I recommend you to look at the source of Java mail servers, Mireka http://code.google.com/p/mireka/ and Apache James http://james.apache.org/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a simple mail server using Python. I found smtpd that
i'm trying to write simple C openssl client and server. Here is client's code:
Hi trying to write a simple linq query from a tutorial I read. But
I am trying to write code to send a simple mail from asp.net page.
i'm trying to write simple tcp\ip client-server. here is server code: internal class Program
I'm trying to write simple proxy server for some purpose. In it I use
Im trying to write a simple sample program which checks for any new mail
I am trying to write simple vector graphics editor in Java and got stuck
I'm trying to write a simple mail retrieval program in python. It seems the
I am trying to write a simple DCT algorithm in java. I want my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.