/// <summary> /// Create a new SMTP client request. /// </summary> /// <param name="actionType">type of action/command</param> /// <param name="request_Params">remainder of command line once command is removed</param> /// <param name="state">current SMTP server state</param> public SmtpRequest(SmtpActionType actionType, string request_Params, SmtpState state) { this.action = actionType; this.state = state; this.request_Params = request_Params; }
/// <summary> /// Create an SMTP request object given a line of the input stream from the client and the current internal state. /// </summary> /// <param name="s">line of input</param> /// <param name="state">current state</param> /// <returns>A populated SmtpRequest object</returns> public static SmtpRequest CreateRequest(string s, SmtpState state) { SmtpActionType action = null; string request_Params = null; if (state == SmtpState.DATA_HDR) { if (s.Equals(".")) { action = SmtpActionType.DATA_END; } else if (s.Length < 1) { action = SmtpActionType.BLANK_LINE; } else { action = SmtpActionType.UNRECOG; request_Params = s; } } else if (state == SmtpState.DATA_BODY) { if (s.Equals(".")) { action = SmtpActionType.DATA_END; } else { action = SmtpActionType.UNRECOG; request_Params = s; } } else { string su = s.ToUpper(); if (su.StartsWith("EHLO ") || su.StartsWith("HELO")) { action = SmtpActionType.EHLO; request_Params = s.Substring(5); } else if (su.StartsWith("MAIL FROM:")) { action = SmtpActionType.MAIL; request_Params = s.Substring(10); } else if (su.StartsWith("RCPT TO:")) { action = SmtpActionType.RCPT; request_Params = s.Substring(8); } else if (su.StartsWith("DATA")) { action = SmtpActionType.DATA; } else if (su.StartsWith("QUIT")) { action = SmtpActionType.QUIT; } else if (su.StartsWith("RSET")) { action = SmtpActionType.RSET; } else if (su.StartsWith("NOOP")) { action = SmtpActionType.NOOP; } else if (su.StartsWith("EXPN")) { action = SmtpActionType.EXPN; } else if (su.StartsWith("VRFY")) { action = SmtpActionType.VRFY; } else if (su.StartsWith("HELP")) { action = SmtpActionType.HELP; } else { action = SmtpActionType.UNRECOG; } } SmtpRequest req = new SmtpRequest(action, request_Params, state); return(req); }
/// <summary> /// Create a new SMTP client request. /// </summary> /// <param name="actionType">type of action/command</param> /// <param name="request_Params">remainder of command line once command is removed</param> /// <param name="state">current SMTP server state</param> public SmtpRequest(SmtpActionType actionType, string request_Params, SmtpState state) { this.action = actionType; this.state = state; this.request_Params = request_Params; }
/// <summary> /// Create a new SMTP client request. /// </summary> /// <param name="actionType">type of action/command</param> /// <param name="requestParams">remainder of command line once command is removed</param> /// <param name="state">current SMTP server state</param> public SmtpRequest(SmtpActionType actionType, string requestParams, SmtpState state) { _action = actionType; _state = state; Params = requestParams; }
/// <summary> /// Create an SMTP request object given a line of the input stream from the client and the current internal state. /// </summary> /// <param name="s">line of input</param> /// <param name="state">current state</param> /// <returns>A populated SmtpRequest object</returns> public static SmtpRequest CreateRequest(string s, SmtpState state) { SmtpActionType action = null; string request_Params = null; if (state == SmtpState.DATA_HDR) { if (s.Equals(".")) { action = SmtpActionType.DATA_END; } else if (s.Length < 1) { action = SmtpActionType.BLANK_LINE; } else { action = SmtpActionType.UNRECOG; request_Params = s; } } else if (state == SmtpState.DATA_BODY) { if (s.Equals(".")) { action = SmtpActionType.DATA_END; } else { action = SmtpActionType.UNRECOG; request_Params = s; } } else { string su = s.ToUpper(); if (su.StartsWith("EHLO ") || su.StartsWith("HELO")) { action = SmtpActionType.EHLO; request_Params = s.Substring(5); } else if (su.StartsWith("MAIL FROM:")) { action = SmtpActionType.MAIL; request_Params = s.Substring(10); } else if (su.StartsWith("RCPT TO:")) { action = SmtpActionType.RCPT; request_Params = s.Substring(8); } else if (su.StartsWith("DATA")) { action = SmtpActionType.DATA; } else if (su.StartsWith("QUIT")) { action = SmtpActionType.QUIT; } else if (su.StartsWith("RSET")) { action = SmtpActionType.RSET; } else if (su.StartsWith("NOOP")) { action = SmtpActionType.NOOP; } else if (su.StartsWith("EXPN")) { action = SmtpActionType.EXPN; } else if (su.StartsWith("VRFY")) { action = SmtpActionType.VRFY; } else if (su.StartsWith("HELP")) { action = SmtpActionType.HELP; } else { action = SmtpActionType.UNRECOG; } } SmtpRequest req = new SmtpRequest(action, request_Params, state); return req; }