SmtpServer.Protocol.SmtpCommandFactory.TryMakeRcpt C# (CSharp) Method

TryMakeRcpt() public method

Make a RCTP command from the given enumerator.
public TryMakeRcpt ( TokenEnumerator enumerator, SmtpCommand &command, SmtpResponse &errorResponse ) : bool
enumerator SmtpServer.Protocol.Text.TokenEnumerator The enumerator to create the command from.
command SmtpCommand The RCTP command that is defined within the token enumerator.
errorResponse SmtpResponse The error that indicates why the command could not be made.
return bool
        public bool TryMakeRcpt(TokenEnumerator enumerator, out SmtpCommand command, out SmtpResponse errorResponse)
        {
            Debug.Assert(enumerator.Peek() == new Token(TokenKind.Text, "RCPT"));

            command = null;
            errorResponse = null;

            enumerator.Take();
            enumerator.TakeWhile(TokenKind.Space);

            if (enumerator.Take() != new Token(TokenKind.Text, "TO") || enumerator.Take() != new Token(TokenKind.Punctuation, ":"))
            {
                errorResponse = new SmtpResponse(SmtpReplyCode.SyntaxError, "missing the TO:");
                return false;
            }

            // according to the spec, whitespace isnt allowed here anyway
            enumerator.TakeWhile(TokenKind.Space);

            IMailbox mailbox;
            if (_parser.TryMakePath(enumerator, out mailbox) == false)
            {
                _logger.LogVerbose("Syntax Error (Text={0})", enumerator.AsText());

                errorResponse = SmtpResponse.SyntaxError;
                return false;
            }

            // TODO: support optional service extension parameters here

            command = new RcptCommand(mailbox, _options.MailboxFilterFactory);
            return true;
        }