Esempio n. 1
0
        public void TestMirrorMultipleRecipients()
        {
            // Create a test account
            // Fetch the default domain
            Account account1 = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            Account account2 = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            Account account3 = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            Account mirrorAccount = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**",
                                                                                       "test");

            _settings.MirrorEMailAddress   = "*****@*****.**";
            _settings.AddDeliveredToHeader = true;

            // Send 5 messages to this account.
            var smtpClientSimulator = new SmtpClientSimulator();

            smtpClientSimulator.Send("*****@*****.**", new List <string> {
                account1.Address, account2.Address, account3.Address
            },
                                     "INBOX", "Mirror test message");

            Pop3ClientSimulator.AssertMessageCount(mirrorAccount.Address, "test", 1);

            string message = Pop3ClientSimulator.AssertGetFirstMessageText(mirrorAccount.Address, "test");

            Assert.IsTrue(message.Contains("Delivered-To: [email protected],[email protected],[email protected]"));

            CustomAsserts.AssertRecipientsInDeliveryQueue(0);
        }
Esempio n. 2
0
        public void TestMirrorMultipleRecipientsOver255Chars()
        {
            // Create a test account
            // Fetch the default domain
            var recipients = new List <string>();

            for (int i = 0; i < 20; i++)
            {
                string address = string.Format("mirror{0}@test.com", i);
                SingletonProvider <TestSetup> .Instance.AddAccount(_domain, address, "test");

                recipients.Add(address);
            }

            Account mirrorAccount = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**",
                                                                                       "test");

            _settings.MirrorEMailAddress   = "*****@*****.**";
            _settings.AddDeliveredToHeader = true;

            // Send 1 messages to this account.
            var smtpClientSimulator = new SmtpClientSimulator();

            smtpClientSimulator.Send("*****@*****.**", recipients, "INBOX", "Mirror test message");

            Pop3ClientSimulator.AssertMessageCount(mirrorAccount.Address, "test", 1);

            string message = Pop3ClientSimulator.AssertGetFirstMessageText(mirrorAccount.Address, "test");

            Assert.IsTrue(
                message.Contains(
                    "Delivered-To: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],mirror14@test\r\n"));

            CustomAsserts.AssertRecipientsInDeliveryQueue(0);
        }
Esempio n. 3
0
        public void TestForwardingAndDelete()
        {
            // Create a test account
            // Fetch the default domain
            Account oAccount1 = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            Account oAccount2 = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            // Set up account 1 to forward to account2.
            oAccount1.ForwardEnabled      = true;
            oAccount1.ForwardAddress      = "*****@*****.**";
            oAccount1.ForwardKeepOriginal = false;
            oAccount1.Save();

            // Send 2 messages to this account.
            var smtpClientSimulator = new SmtpClientSimulator();

            smtpClientSimulator.Send("*****@*****.**", "*****@*****.**", "INBOX", "POP3 test message");
            CustomAsserts.AssertRecipientsInDeliveryQueue(0);
            Pop3ClientSimulator.AssertMessageCount(oAccount2.Address, "test", 1);

            string domainDir = Path.Combine(_settings.Directories.DataDirectory, "test.com");
            string userDir   = Path.Combine(domainDir, "Forward1");

            string[] dirs = Directory.GetDirectories(userDir);
            foreach (string dir in dirs)
            {
                string[] files = Directory.GetFiles(dir);

                Assert.AreEqual(0, files.Length);
            }
        }
Esempio n. 4
0
        public void ConfirmSingleReturnPathAfterAccountForward()
        {
            // Create a test account
            // Fetch the default domain
            Account oAccount1 = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            Account oAccount2 = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            oAccount1.ForwardAddress = oAccount2.Address;
            oAccount1.ForwardEnabled = true;
            oAccount1.Save();

            // Send a message...
            var smtpClientSimulator = new SmtpClientSimulator();

            smtpClientSimulator.Send("*****@*****.**", oAccount1.Address, "Test message", "This is the body");

            CustomAsserts.AssertRecipientsInDeliveryQueue(0);
            _application.SubmitEMail();

            // Wait for the auto-reply.
            string text = Pop3ClientSimulator.AssertGetFirstMessageText(oAccount2.Address, "test");

            Assert.IsFalse(text.Contains("Return-Path: [email protected]"));
            Assert.IsFalse(text.Contains("Return-Path: [email protected]"));
            Assert.IsTrue(text.Contains("Return-Path: [email protected]"));
        }
Esempio n. 5
0
        public void TestAutoReplyCombinedWithForwarding()
        {
            // Create a test account
            // Fetch the default domain
            Account oAccount1 = SingletonProvider <TestSetup> .Instance.AddAccount(_domain,
                                                                                   TestSetup.UniqueString() + "@test.com",
                                                                                   "test");

            Account oAccount2 = SingletonProvider <TestSetup> .Instance.AddAccount(_domain,
                                                                                   TestSetup.UniqueString() + "@test.com",
                                                                                   "test");

            Account oAccount3 = SingletonProvider <TestSetup> .Instance.AddAccount(_domain,
                                                                                   TestSetup.UniqueString() + "@test.com",
                                                                                   "test");

            oAccount2.VacationMessageIsOn = true;
            oAccount2.VacationMessage     = "I'm on vacation";
            oAccount2.VacationSubject     = "Out of office!";

            oAccount2.ForwardAddress      = oAccount3.Address;
            oAccount2.ForwardEnabled      = true;
            oAccount2.ForwardKeepOriginal = true;
            oAccount2.Save();

            // Send a message...
            var smtpClientSimulator = new SmtpClientSimulator();

            smtpClientSimulator.Send(oAccount1.Address, oAccount2.Address, "Test message", "This is the body");

            SingletonProvider <TestSetup> .Instance.GetApp().SubmitEMail();

            CustomAsserts.AssertRecipientsInDeliveryQueue(0);

            // Wait for the auto-reply.
            Pop3ClientSimulator.AssertMessageCount(oAccount1.Address, "test", 1);
            Pop3ClientSimulator.AssertMessageCount(oAccount2.Address, "test", 1);
            Pop3ClientSimulator.AssertMessageCount(oAccount3.Address, "test", 1);
        }
Esempio n. 6
0
        private void DownloadFromExternalAccount(Account account, FetchAccount fa)
        {
            if (!_backupMessages)
            {
                return;
            }

            // Download messages from the external account.
            var messages = new List <string>();

            messages.Add("Subject: Message 1\r\n");
            messages.Add("Subject: Message 2\r\n");
            messages.Add("Subject: Message 3\r\n");

            using (var pop3Server = new Pop3ServerSimulator(1, fa.Port, messages))
            {
                pop3Server.StartListen();
                fa.DownloadNow();
                pop3Server.WaitForCompletion();
            }

            CustomAsserts.AssertRecipientsInDeliveryQueue(0);
            Pop3ClientSimulator.AssertMessageCount(account.Address, "test", 5);
        }