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 8601473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:51:09+00:00 2026-06-12T01:51:09+00:00

I am coding POP3 and SMTP servers using Java for an university project. I

  • 0

I am coding POP3 and SMTP servers using Java for an university project.
I can send emails using my SMTP server via a client (ie: Thunderbird) and my server sends them without any problem.

When an external sender agent, like gmail or hotmail, tries to send an email using my SMTP server, it does not complete the communication because it sends the QUIT command after the MAIL command. Why the external agent does that? Didn’t I obey to the SMTP protocol?

The problem is that when I receive a connection from the an external server that wants to send me mail the following happens (me: my SMTP server, sender: sender agent). Here is an example with a gmail agent.


sender: establishes a connection
me: 220 Welcome
sender: HELO agent id
me: 250 Fine
sender: MAIL FROM:<address@gmail.com>
me (after address verification): 250
sender: QUIT
me: 221

Relevant code snippets (full class code is at http://code.google.com/p/sd-mail-server-claudiani-ferrari/source/browse/src/controller/smtp/SMTPCommandHandler.java?repo=mailserver )

private void MAILCommand(CommunicationHandler communicationHandler, 
                         BufferedOutputStream writer, 
                         PersistanceManager persistanceManager, 
                         String clientId, 
                         String argument) 
{
    String address = getAddressFromArgument(argument);
    if (!isValidAddress(address, persistanceManager)) {
        communicationHandler.sendResponse(writer, 
                                          SMTPCode.SYNTAX_ERROR.toString(), 
                                          "Address is not valid.");
        return;
    }

    // Initialize data
    persistanceManager.create(StorageLocation.SMTP_TEMP_MESSAGE_STORE, 
                              FieldName.getSMTPTempTableFromFieldOnly(), 
                              clientId, address);

    communicationHandler.sendResponse(writer, SMTPCode.OK.toString(), "");

}

private void RCPTCommand(CommunicationHandler communicationHandler, 
                         BufferedOutputStream writer, 
                         PersistanceManager persistanceManager, 
                         String clientId, 
                         String argument) 
{
    String address = getAddressFromArgument(argument);
    // Check the address
    if (!isValidAddress(address, persistanceManager)) {
        communicationHandler.sendResponse(writer, 
                                          SMTPCode.SYNTAX_ERROR.toString(), 
                                          "Address is not valid.");
        return;
    }

    persistanceManager.addToSet(StorageLocation.SMTP_TEMP_MESSAGE_STORE, 
                                clientId, 
                                FieldName.SMTP_TEMP_TO_ADDRESSES, 
                                address);

    communicationHandler.sendResponse(writer, SMTPCode.OK.toString(), "");
}

private void DATACommand(CommunicationHandler communicationHandler, 
                         BufferedOutputStream writer, 
                         PersistanceManager persistanceManager, 
                         String clientId) 
{
    communicationHandler.sendResponse(writer, 
                                      SMTPCode.INTERMEDIATE_REPLY.toString(), 
                                      "Start mail input; end with [CRLF].[CRLF]");
}
  • 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-06-12T01:51:11+00:00Added an answer on June 12, 2026 at 1:51 am

    Have you tried replying with 250 OK instead of just 250 ? RFC 2821 says that this should be the reply of a MAIL FROM line:

    If accepted, the SMTP server returns
    a 250 OK reply. If the mailbox specification is not acceptable for
    some reason, the server MUST return a reply indicating whether the

    Your mail client might be satisfied with seeing 250, while Google/Hotmail might expect 250 OK.

    Edit

    I think the text string isn’t optional in this case, see section 4.2 of RFC 2821:

    An SMTP reply consists of a three digit number (transmitted as
    three numeric characters) followed by some text unless specified
    otherwise in this document.

    The current RFC 5321 suggests that clients should accept no text:

    An SMTP client MUST determine its actions only by the reply code,
    not by the text (except for the "change of address" 251 and 551
    and, if necessary, 220, 221, and 421 replies); in the general case,
    any text, including no text at all (although senders SHOULD NOT
    send bare codes
    ), MUST be acceptable. The space (blank) following
    the reply code is considered part of the text. Whenever possible,
    a receiver- SMTP SHOULD test the first digit (severity indication)
    of the reply code.

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

Sidebar

Related Questions

Im coding in Java.. Does anyone know how i can get the content of
I'm currently coding, as the part of a bigger project, a webmail client. I'd
Happy coding weekend to everyone!!!. I'm stuck trying to send a JSON object via
Coding i came around to check for the vararg performance of Java. I write
After coding and testing a Java application (lets say with Eclipse, but not necessarily)
While coding python I'm using only 2 spaces to indent, sure PEP-8 really recommend
When coding in Java in Eclipse, is there a shortcut similar to typing syso
Coding for PHP on Mac OSX Lion, using the following within the httpd.conf file:
Coding standards in place mean I do not have an option of using ajax
When coding Java in Eclipse, it often tries to predict what you're typing. For

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.