public void ToString_MultiLineMessage() { SmtpResponse r = new SmtpResponse(200, "Multi line message line 1\r\n" + "Multi line message line 2\r\n" + "Multi line message line 3"); Assert.Equal("200-Multi line message line 1\r\n" + "200-Multi line message line 2\r\n" + "200 Multi line message line 3\r\n", r.ToString()); }
public void ToString_MultiLineMessage() { var r = new SmtpResponse(200, "Multi line message line 1\r\n" + "Multi line message line 2\r\n" + "Multi line message line 3"); Assert.Equal("200-Multi line message line 1\r\n" + "200-Multi line message line 2\r\n" + "200 Multi line message line 3\r\n", r.ToString()); }
public void RunCommand(string command, SmtpResponse expectedSmtpResponse) { _writer.WriteLine(command); var line = _reader.ReadLine(); if (line == null) throw new InvalidOperationException("Stream has unexpectedly closed"); if (line != expectedSmtpResponse.ToString()) throw new InvalidOperationException(String.Format("After command '{0}' received '{1}' but expected '{2}'", command, line, expectedSmtpResponse)); }
public void RunCommand(string command, SmtpResponse expectedSmtpResponse) { _writer.WriteLine(command); var line = _reader.ReadLine(); if (line == null) { throw new InvalidOperationException("Stream has unexpectedly closed"); } if (line != expectedSmtpResponse.ToString()) { throw new InvalidOperationException(String.Format("After command '{0}' received '{1}' but expected '{2}'", command, line, expectedSmtpResponse)); } }
public void ToString_SingleLineMessage() { var r = new SmtpResponse(200, "Single line message"); Assert.Equal("200 Single line message\r\n", r.ToString()); }
public override void AckRecipient(AckStatus ackStatus, SmtpResponse smtpResponse) { TraceHelper.SmtpSendTracer.TracePass <string, string>(TraceHelper.MessageProbeActivityId, (long)this.GetHashCode(), "InboundProxyNextHopConnection.AckRecipient. Ackstatus = {0}. SmtpResponse = {1}", ackStatus.ToString(), smtpResponse.ToString()); if (!this.recipientEnumeratorAck.MoveNext() || this.recipientsPending <= 0) { throw new InvalidOperationException("AckRecipient called but no recipients left to ack"); } this.recipientsPending--; MailRecipient recipient = this.recipientEnumeratorAck.Current; switch (ackStatus) { case AckStatus.Pending: case AckStatus.Success: case AckStatus.Retry: case AckStatus.Fail: if (this.result == null) { this.result = new SmtpMailItemResult(); } if (this.result.RecipientResponses == null) { this.result.RecipientResponses = new Dictionary <MailRecipient, AckStatusAndResponse>(); } this.result.RecipientResponses.Add(recipient, new AckStatusAndResponse(ackStatus, smtpResponse)); if (this.notificationHandler != null) { this.notificationHandler.AckRecipient(ackStatus, smtpResponse, recipient); } return; default: throw new InvalidOperationException(string.Format("AckRecipient with status: {0} is invalid", ackStatus)); } }
public ConnectionSkipException(SmtpResponse response) : base(new LocalizedString(response.ToString())) { this.SmtpResponse = response; }
public ThreadLimitExceededException(SmtpResponse response) : base(new LocalizedString(response.ToString())) { this.SmtpResponse = response; }
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.ToString()); }
public SmtpResponseException(SmtpResponse response, MessageAction action) : base(new LocalizedString(response.ToString())) { if (action == MessageAction.Throw) { throw new ArgumentException("MessageAction.Throw is not supported.", "action"); } this.status = new MessageStatus(action, response, this); }
public SmtpResponseException(SmtpResponse response, string source) : base(new LocalizedString(response.ToString())) { MessageAction action; switch (response.SmtpResponseType) { case SmtpResponseType.Success: if (string.IsNullOrEmpty(source)) { throw new ArgumentException("Source must be provided for success smtp response type", "source"); } action = MessageAction.LogProcess; goto IL_6E; case SmtpResponseType.TransientError: action = MessageAction.Retry; goto IL_6E; case SmtpResponseType.PermanentError: action = MessageAction.NDR; goto IL_6E; } throw new ArgumentException("The smtp response type is not supported.", "response"); IL_6E: this.status = new MessageStatus(action, response, this, false, source); }
public void ToString_SingleLineMessage() { SmtpResponse r = new SmtpResponse(200, "Single line message"); Assert.Equal("200 Single line message\r\n", r.ToString()); }