private function write($command, $code = null, $message = null)
    {
        if ($message == null) {
            $message = $command;
        }

        $command = $command . Message::END;

        fwrite($this->sock, $command, strlen($command));

        $response = null;


        if ($code !== null) {
            $response = $this->read();

            if (!in_array($response, (array) $code)) {
                $message = isset($message) ? $message : '';

                throw new SmtpException(
                    sprintf('SMTP server did not accept %s with code [%s]', $message, $response),
                    E_ERROR
                );
            }
        }

        return $response;
    }