title: RCPT TO: <rcpt@host> SMTP syntax
body: <p>I have a bit of code that fails to successfully execute, and I am failing to understand why.</p>
  <p>This function:</p>
  <pre><code>public void send(Envelope envelope) throws IOException
  {
          String CRLF = &quot;\r\n&quot;;
      sendCommand(&quot;MAIL FROM:&quot;+ envelope.Sender + CRLF, 250);
      
      //error occuring here. &quot;Return Code:500 #5.5.1 command not recognized&quot;
      sendCommand(&quot;RCPT TO:&quot; + envelope.Recipient + CRLF, 250);
      sendCommand(&quot;DATA&quot;, 354);
      toServer.print(envelope.Message.Headers + CRLF);
      toServer.print(envelope.Message.Body + CRLF);
      toServer.print(&quot;.&quot; +CRLF);
  }
  </code></pre>
  <p>The above code calls this Function:</p>
  <pre><code>private void sendCommand(String command, int rc) throws IOException
  {
      /* Write command to server */
      toServer.print(command + CRLF);
      
      /*read reply from server. */
      String line = fromServer.readLine();
      
      System.err.println(&quot;Request: &quot; + command);
      System.err.println(&quot;Return Code:&quot; + line);
      
      
      /*
       * Check that the server's reply code is the same as the parameter rc.
       * If not, throw an IOException.
       */
      if (!line.substring(0,3).equals(rc+&quot;&quot;))
      {
          throw new IOException();
      }
  }
  </code></pre>
  <p>And the inforation is transmitted thus:</p>
  <pre><code>Socket connection = new Socket(envelope.DestAddr, SMTP_PORT); 
      fromServer = new BufferedReader(new InputStreamReader(connection.getInputStream()));
      toServer = new PrintStream(connection.getOutputStream());
  </code></pre>
  <p>I am using the same From and To. And for some reason the RCPT TO: command is met with an error saying:</p>
  <blockquote>
  <p>&quot;Return Code:500 #5.5.1 command not recognized&quot;</p>
  </blockquote>
  <p><strong>EDIT:</strong> I did try them manually by telnetting</p>