Пример #1
0
        public void QmailNoHostFound()
        {
            var message = MimeMessage.Load(OpenFixture("bounce_qmail_no_host_found.eml"));

            var result = BounceDetector.Detect(message);

            Assert.True(result.IsBounce);
            Assert.True(result.IsHard);
            Assert.False(result.IsSoft);
            Assert.Equal("5 Permanent Failure", result.PrimaryStatus.ToString());
            Assert.Equal("3 Mail System Status", result.SecundaryStatus.ToString());
            Assert.Equal("30 Other or undefined mail system status", result.CombinedStatus.ToString());
            Assert.Null(result.RemoteMta);
            Assert.Equal("silverton.berkeley.edu", result.ReportingMta);
            Assert.Equal("*****@*****.**", result.FinalRecipient);
            Assert.Equal("*****@*****.**", result.UndeliveredMessageId);
            Assert.IsType <TextPart>(result.DeliveryNotificationPart);
            Assert.NotNull(result.DeliveryStatus);
            Assert.IsType <MessagePart>(result.UndeliveredMessagePart);
            Assert.NotNull(result.DiagnosticCodes);
            Assert.Equal(2, result.DiagnosticCodes.Length);
            Assert.Equal("", result.DiagnosticCodes[0]);
            Assert.Equal("Sorry, I couldn't find any host by that name.", result.DiagnosticCodes[1]);
            Assert.Equal("failed", result.Action);
        }
Пример #2
0
        public void PostfixNonExistingMailbox()
        {
            var message = MimeMessage.Load(OpenFixture("bounce_postfix_non_existing_mailbox.eml"));

            var result = BounceDetector.Detect(message);

            Assert.True(result.IsBounce);
            Assert.True(result.IsHard);
            Assert.False(result.IsSoft);
            Assert.Equal("5 Permanent Failure", result.PrimaryStatus.ToString());
            Assert.Equal("1 Addressing Status", result.SecundaryStatus.ToString());
            Assert.Equal("11 Bad destination mailbox address", result.CombinedStatus.ToString());
            Assert.Null(result.RemoteMta);
            Assert.Equal("test.local", result.ReportingMta);
            Assert.Equal("*****@*****.**", result.FinalRecipient);
            Assert.Equal("*****@*****.**", result.UndeliveredMessageId);
            Assert.IsType <TextPart>(result.DeliveryNotificationPart);
            Assert.NotNull(result.DeliveryStatus);
            Assert.IsType <MessagePart>(result.UndeliveredMessagePart);
            Assert.NotNull(result.DiagnosticCodes);
            Assert.Equal(2, result.DiagnosticCodes.Length);
            Assert.Equal("", result.DiagnosticCodes[0]);
            Assert.Equal("unknown user:    \"[email protected]\"", result.DiagnosticCodes[1]);
            Assert.Equal("failed", result.Action);
        }
Пример #3
0
        public void QmailWrappedInMultipartAlternateNonExistingMailbox()
        {
            var message = MimeMessage.Load(OpenFixture("bounce_qmail_multipart_alternative_non_existing_mailbox.eml"));

            var result = BounceDetector.Detect(message);

            Assert.True(result.IsBounce);
            Assert.True(result.IsHard);
            Assert.False(result.IsSoft);
            Assert.Equal("5 Permanent Failure", result.PrimaryStatus.ToString());
            Assert.Equal("7 Security or Policy Status", result.SecundaryStatus.ToString());
            Assert.Equal("71 Delivery not authorized, message refused", result.CombinedStatus.ToString());
            Assert.Null(result.RemoteMta);
            Assert.Equal("mgm-smtp.example.com", result.ReportingMta);
            Assert.Equal("*****@*****.**", result.FinalRecipient);
            Assert.Null(result.UndeliveredMessageId);
            Assert.IsType <TextPart>(result.DeliveryNotificationPart);
            Assert.NotNull(result.DeliveryStatus);
            Assert.IsType <MessagePart>(result.UndeliveredMessagePart);
            Assert.NotNull(result.DiagnosticCodes);
            Assert.Equal(2, result.DiagnosticCodes.Length);
            Assert.Equal("4.3.2.1", result.DiagnosticCodes[0]);
            Assert.Equal("does not like recipient. Remote host said: 554 5.7.1 <*****@*****.**>: Relay access denied Giving up on 4.3.2.1.", result.DiagnosticCodes[1]);
            Assert.Equal("failed", result.Action);
        }
Пример #4
0
        public void NonBouncePostfix()
        {
            var message = MimeMessage.Load(OpenFixture("non_bounce_postfix_hello_world.eml"));

            var result = BounceDetector.Detect(message);

            Assert.False(result.IsBounce);
            Assert.False(result.IsHard);
            Assert.False(result.IsSoft);
        }
Пример #5
0
        public void ExchangeNonExistingMailbox()
        {
            var message = MimeMessage.Load(OpenFixture("bounce_exchange_non_existing_mailbox.eml"));

            var result = BounceDetector.Detect(message);

            Assert.True(result.IsBounce);
            Assert.True(result.IsHard);
            Assert.False(result.IsSoft);
            Assert.Equal("5 Permanent Failure", result.PrimaryStatus.ToString());
            Assert.Equal("1 Addressing Status", result.SecundaryStatus.ToString());
            Assert.Equal("11 Bad destination mailbox address", result.CombinedStatus.ToString());
            Assert.Equal("mx.google.com", result.RemoteMta);
            Assert.Equal("test.local", result.ReportingMta);
            Assert.Equal("*****@*****.**", result.FinalRecipient);
            Assert.Equal("*****@*****.**", result.UndeliveredMessageId);
            Assert.IsType <TextPart>(result.DeliveryNotificationPart);
            Assert.NotNull(result.DeliveryStatus);
            Assert.IsType <MessagePart>(result.UndeliveredMessagePart);
            Assert.Null(result.DiagnosticCodes);
            Assert.Equal("failed", result.Action);
        }
Пример #6
0
        public void QmailExtraLinesBetweenRecipientParagraphs()
        {
            var message = MimeMessage.Load(OpenFixture("bounce_qmail_extra_lines_between_recipient_paragraphs.eml"));

            var result = BounceDetector.Detect(message);

            Assert.True(result.IsBounce);
            Assert.True(result.IsHard);
            Assert.False(result.IsSoft);
            Assert.Equal("5 Permanent Failure", result.PrimaryStatus.ToString());
            Assert.Equal("3 Mail System Status", result.SecundaryStatus.ToString());
            Assert.Equal("30 Other or undefined mail system status", result.CombinedStatus.ToString());
            Assert.Null(result.RemoteMta);
            Assert.Equal("example.com", result.ReportingMta);
            // NB even though there are multiple failure paragraphs, only the last one is returned here.
            Assert.Equal("*****@*****.**", result.FinalRecipient);
            Assert.Equal("*****@*****.**", result.UndeliveredMessageId);
            Assert.IsType <TextPart>(result.DeliveryNotificationPart);
            Assert.NotNull(result.DeliveryStatus);
            Assert.Equal(3, result.DeliveryStatus.StatusGroups.Count);
            Assert.Equal("dns;example.com", result.DeliveryStatus.StatusGroups[0]["Reporting-MTA"]);
            Assert.Equal("rfc822;[email protected]", result.DeliveryStatus.StatusGroups[1]["Final-Recipient"]);
            Assert.Equal("rfc822;[email protected]", result.DeliveryStatus.StatusGroups[2]["Final-Recipient"]);
            Assert.IsType <MessagePart>(result.UndeliveredMessagePart);
            var undeliveredMessage = ((MessagePart)result.UndeliveredMessagePart).Message;

            Assert.Equal("are you there?", undeliveredMessage.Subject);
            Assert.Equal("Just checking.", undeliveredMessage.TextBody);
            Assert.Equal(2, undeliveredMessage.To.Count);
            Assert.Equal("*****@*****.**", undeliveredMessage.To[0].ToString());
            Assert.Equal("*****@*****.**", undeliveredMessage.To[1].ToString());
            Assert.NotNull(result.DiagnosticCodes);
            Assert.Equal(2, result.DiagnosticCodes.Length);
            Assert.Equal("", result.DiagnosticCodes[0]);
            Assert.Equal("Sorry, I couldn't find any host by that name.", result.DiagnosticCodes[1]);
            Assert.Equal("failed", result.Action);
        }