Problem with greeting

Ofer Lavi
2004-10-17
2013-04-08
  • Ofer Lavi

    Ofer Lavi - 2004-10-17

    Right after my EHLO greeting, I get:

    250-mydomain.com Hello hostname, ESMTP hello!

    I then send the "FROM" command, but instead of getting the "sender ok", I get:

    250-EXPN
    250-ETRN
    250-AUTH LOGIN CRAM-MD5
    250-8BITMIME
    250 SIZE 0

    Now, this should be a part of the greeting, but I don't get it in my 1st recv.

    After sending the RCPT TO: I get:
    250-...Sender ok
    etc.

    sending fails when I send DATA, and expects for 354, but get 250-Recipient OK

    Is my server buggy?

     
    • Ofer Lavi

      Ofer Lavi - 2004-10-17

      Well, a friend checked it out, and found that the RFC says that the server can reply with many lines, each starting with the code (e.g. 250) and ending with a newline. However - the last line has no dash after the code, while the other lines have.
      Here is a proposal for a better parsing, modifying the Recv function:

      bool Recv( int& CharsRecv, SOCKET s, char* buf, size_t len, int flags )
      {
         char* pStartLine = buf;

         while( len > 0 )
         {
            CharsRecv = recv( s, buf, len, flags );

            if( CharsRecv == SOCKET_ERROR ) {
               return false;
            }

            len -= CharsRecv;

            if( len > 0 ) {
               buf[ CharsRecv ] = '\0';
            }

            if( buf[ CharsRecv - 1 ] == '\n' && buf + CharsRecv - pStartLine >= 5 )
            {
               for( pStartLine = buf + CharsRecv - 2; pStartLine > buf; --pStartLine )
               {
                  if( *( pStartLine - 1 ) == '\n' ) {
                     break;
                  }
               }

               if( isdigit( pStartLine[ 0 ] ) && isdigit( pStartLine[ 1 ] ) &&
                  isdigit( pStartLine[ 2 ] ) && ( pStartLine[ 3 ] == '\r' || pStartLine[
      3 ] == '\x20' ) )
               {
                  return true;
               }
            }

            buf += CharsRecv;
         }

         return true;
      }

      It seems like a bug in jwsmtp, not expecting a "broken" message from the server.

      Lavio.

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks