private static async Task SendResponseAsync(SmtpConnection connection, SmtpResponse response) { LogResponse(response); foreach (var additional in response.AdditionalLines) { await connection.WriteLineAsyncAndFireEvents(additional); } await connection.WriteLineAsyncAndFireEvents(response.ResponseCode + " " + response.ResponseText); }
private static bool IsLineTooLong(byte[] lineBuf, out SmtpResponse smtpResponse) { if (lineBuf.Length > 2040) { smtpResponse = SmtpResponse.LineTooLong; return(true); } smtpResponse = SmtpResponse.None; return(false); }
private SmtpResponse VerifyEhlo() { var smtpCapabilities = _getSmtpCapabilities.GetCapabilities().ToList(); if (!smtpCapabilities.Any()) { return(SmtpResponses.OK); } var additionalLines = smtpCapabilities.Skip(1).Select(capability => "250-" + capability).ToList(); var response = new SmtpResponse(250, smtpCapabilities.First().ToString(), additionalLines); return(response); }
private static async Task SendResponseAsync(SmtpConnection connection, SmtpResponse response) { LogResponse(response); try { foreach (var additional in response.AdditionalLines) { await connection.WriteLineAsyncAndFireEvents(additional); } await connection.WriteLineAsyncAndFireEvents(response.ResponseCode + " " + response.ResponseText); } catch (Exception ex) { MailServerLogger.Instance.Error(ex); } }
private static void LogResponse(SmtpResponse response) { var logger = MailServerLogger.Instance; if (logger.LogLevel < MailServerLogLevel.Debug) { return; } var logMessage = new StringBuilder(); foreach (var additionalLine in response.AdditionalLines) { logMessage.AppendLine(">>> " + additionalLine); } logMessage.AppendLine(">>> " + response.ResponseCode + " " + response.ResponseText); logger.Debug(logMessage.ToString()); }
private SmtpResponse VerifyEhlo() { var response = new SmtpResponse(250, "SIZE " + Configuration.MaxMailMessageSize, new[] { "250-PIPELINING" }); return(response); }
private bool ProcessRawLineHasResponse(string line, out SmtpResponse smtpResponse) { smtpResponse = ProcessRawLine(line); return(smtpResponse != SmtpResponse.None); }