protected Response receive() throws IOException {
        if (!connected) {
            throw new IllegalStateException("Not connected");
        }

        final StringBuilder builder = new StringBuilder();
        String line = null;

        boolean done = false;
        do {
            line = this.reader.readLine();
            if (line == null) {
                if (builder.length() == 0) {
                    throw new EOFException("Server disconnected unexpectedly, no reply received");
                }
                throw new IOException(MALFORMED_SMTP_REPLY + builder);
            }

            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Server: {}", line);
            }

            if (line.length() < 4) {
                throw new IOException(MALFORMED_SMTP_REPLY + line);
            }
            builder.append(line.substring(4));

            if (line.charAt(3) == '-') {
                builder.append('\n');
            } else {
                done = true;
            }
        } while (!done);

        int code;
        final String codeString = line.substring(0, 3);
        try {
            code = Integer.parseInt(codeString);
        } catch (final NumberFormatException e) {
            throw new IOException(MALFORMED_SMTP_REPLY + line, e);
        }

        return new Response(code, builder.toString());
    }
Note that the response text comes back without trailing newlines.
src/test/java/de/gessnerfl/fakesmtp/smtp/client/SMTPClient.java