/// <summary> /// Make a HELO command from the given enumerator. /// </summary> /// <param name="command">The HELO command that is defined within the token enumerator.</param> /// <param name="errorResponse">The error that indicates why the command could not be made.</param> /// <returns>Returns true if a command could be made, false if not.</returns> public bool TryMakeHelo(out SmtpCommand command, out SmtpResponse errorResponse) { command = null; errorResponse = null; Enumerator.Take(); Enumerator.Skip(TokenKind.Space); if (TryMakeDomain(out var domain)) { command = new HeloCommand(_options, domain); return(true); } // according to RFC5321 the HELO command should only accept the Domain // and not the address literal, however some mail clients will send the // address literal and there is no harm in accepting it if (TryMakeAddressLiteral(out var address)) { command = new HeloCommand(_options, address); return(true); } errorResponse = SmtpResponse.SyntaxError; return(false); }
/// <summary> /// Make a HELO command from the given enumerator. /// </summary> /// <param name="command">The HELO command that is defined within the token enumerator.</param> /// <param name="errorResponse">The error that indicates why the command could not be made.</param> /// <returns>Returns true if a command could be made, false if not.</returns> public bool TryMakeHelo(out SmtpCommand command, out SmtpResponse errorResponse) { command = null; errorResponse = null; Enumerator.Take(); Enumerator.Skip(TokenKind.Space); if (TryMakeDomain(out string domain) == false) { _options.Logger.LogVerbose("Could not match the domain name (Text={0}).", CompleteTokenizedText()); errorResponse = SmtpResponse.SyntaxError; return(false); } command = new HeloCommand(_options, domain); return(true); }
/// <summary> /// Make a HELO command from the given enumerator. /// </summary> /// <param name="enumerator">The enumerator to create the command from.</param> /// <param name="command">The HELO command that is defined within the token enumerator.</param> /// <param name="errorResponse">The error that indicates why the command could not be made.</param> /// <returns>Returns true if a command could be made, false if not.</returns> public bool TryMakeHelo(TokenEnumerator enumerator, out SmtpCommand command, out SmtpResponse errorResponse) { Debug.Assert(enumerator.Peek() == new Token(TokenKind.Text, "HELO")); command = null; errorResponse = null; enumerator.Take(); enumerator.TakeWhile(TokenKind.Space); string domain; if (_parser.TryMakeDomain(enumerator, out domain) == false) { _logger.LogVerbose("Could not match the domain name (Text={0}).", enumerator.AsText()); errorResponse = SmtpResponse.SyntaxError; return(false); } command = new HeloCommand(domain); return(true); }
/// <summary> /// Make a HELO command from the given enumerator. /// </summary> /// <param name="enumerator">The enumerator to create the command from.</param> /// <param name="command">The HELO command that is defined within the token enumerator.</param> /// <param name="errorResponse">The error that indicates why the command could not be made.</param> /// <returns>Returns true if a command could be made, false if not.</returns> public bool TryMakeHelo(TokenEnumerator enumerator, out SmtpCommand command, out SmtpResponse errorResponse) { Debug.Assert(enumerator.Peek() == new Token(TokenKind.Text, "HELO")); command = null; errorResponse = null; enumerator.Take(); enumerator.TakeWhile(TokenKind.Space); string domain; if (_parser.TryMakeDomain(enumerator, out domain) == false) { _logger.LogVerbose("Could not match the domain name (Text={0}).", enumerator.AsText()); errorResponse = SmtpResponse.SyntaxError; return false; } command = new HeloCommand(domain); return true; }
/// <summary> /// Visit a HELO command. /// </summary> /// <param name="command">The command that is being visited.</param> protected virtual void Visit(HeloCommand command) { }