Exemplo n.º 1
0
        public void TestSearchUTF8TEXT()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string body = Utilities.GetResource("Messages.MessageContainingGreekSubject.txt");

            SMTPClientSimulator.StaticSendRaw(account.Address, account.Address, body);

            POP3Simulator.AssertMessageCount(account.Address, "test", 1);

            IMAPSimulator oSimulator = new IMAPSimulator();

            Assert.IsTrue(oSimulator.ConnectAndLogon(account.Address, "test"));
            Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

            string result = oSimulator.Search("CHARSET UTF-8 ALL TEXT GRΣΣK");

            Assert.AreEqual("1", result);

            result = oSimulator.Search("CHARSET UTF-8 ALL TEXT 標準語");
            Assert.AreEqual("1", result);

            result = oSimulator.Search("CHARSET UTF-8 ALL TEXT GRΣΣK標準語");
            Assert.AreEqual("1", result);

            result = oSimulator.Search("CHARSET UTF-8 ALL TEXT GRΣΣKWHAT標準語");
            Assert.AreEqual("", result);
        }
Exemplo n.º 2
0
        public void TestUpdateSubjectOnMessageWithNoMessageWideCharacterSet()
        {
            Account account = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string script = "Sub OnAcceptMessage(oClient, oMessage) " + Environment.NewLine +
                            " oMessage.Subject = \"[ov]\" + oMessage.Subject " + Environment.NewLine +
                            " oMessage.Save() " + Environment.NewLine +
                            "End Sub" + Environment.NewLine + Environment.NewLine;

            Scripting scripting = _settings.Scripting;

            File.WriteAllText(scripting.CurrentScriptFile, script);
            scripting.Enabled = true;
            scripting.Reload();
            CustomAssert.IsEmpty(scripting.CheckSyntax());

            string body = @"From: <*****@*****.**>" + Environment.NewLine +
                          "Subject: =?windows-1251?B?yuDr7Pvq7uLzIMji4O3zIC0g7/Do7OXwICLy5fXt6Pfl8eru4+4g8OX4?=" +
                          Environment.NewLine +
                          "   =?windows-1251?B?5e3o/yIgW0Z3ZDog0tAg4uXw8ejoIDEuMl0=?=" + Environment.NewLine +
                          Environment.NewLine +
                          "Hej!" + Environment.NewLine;


            SMTPClientSimulator.StaticSendRaw("*****@*****.**", "*****@*****.**", body);

            POP3ClientSimulator.AssertMessageCount(account.Address, "test", 1);

            TestSetup.AssertFolderMessageCount(account.IMAPFolders[0], 1);

            string subject = account.IMAPFolders[0].Messages[0].Subject;
        }
        public void TestValidSignatureSHA256()
        {
            _antiSpam.DKIMVerificationEnabled      = true;
            _antiSpam.DKIMVerificationFailureScore = 100;

            string messageText = @"Return-Path: <*****@*****.**>" + "\r\n" +
                                 "X-Original-To: [email protected]" + "\r\n" +
                                 "Delivered-To: [email protected]" + "\r\n" +
                                 "Received: from voicemail.cis.att.net (unknown [12.34.200.188])" + "\r\n" +
                                 "	by mx2.messiah.edu (Postfix) with ESMTP id 02F12E15D8"+ "\r\n" +
                                 "	for <*****@*****.**>; Wed,  3 May 2006 15:06:32 -0400 (EDT)"+ "\r\n" +
                                 "Received: from  (localhost[127.0.0.1]) by voicemail.cis.att.net (vm2) with SMTP" + "\r\n" +
                                 "          id <2006050319071918800spa0re>; Wed, 3 May 2006 19:07:19 +0000" + "\r\n" +
                                 "DKIM-Signature: a=rsa-sha256;  c=relaxed; d=vmt2.cis.att.net; t=1146680862; " + "\r\n" +
                                 " h=Date : From : MIME-Version : To : Subject : Content-Type : Content-Transfer-Encoding; bh=HryPFX2R6r7JPsX1Z7+yReZddQR2PjvCvdXgaxW5QYU=; s=shan; " + "\r\n" +
                                 " b=QXd8h2UbBO7fIPz/Iy3wNwbVU6dih6ozokPXqAvI6p9iG5SqFahyTXwqZeltC4az3Sjay7Vx+b5e" + "\r\n" +
                                 " 1s2rQuhT4SKD47gJYs4kw0JgV2WLanF3oR1hWD0tL0vuDeUgH6kr" + "\r\n" +
                                 "Date: Wed, 15 Feb 2006 17:32:54 -0500" + "\r\n" +
                                 "From: Tony Hansen <*****@*****.**>" + "\r\n" +
                                 "MIME-Version: 1.0" + "\r\n" +
                                 "To: [email protected], [email protected], [email protected]" + "\r\n" +
                                 "Subject: this is a test message minimum.ietf-01.sha256-relaxed" + "\r\n" +
                                 "Content-Type: text/plain; charset=ISO-8859-1" + "\r\n" +
                                 "Content-Transfer-Encoding: 7bit" + "\r\n" +
                                 "Message-Id: <*****@*****.**>" + "\r\n" +
                                 "" + "\r\n" +
                                 "The quick brown fox jumped over the lazy dog." + "\r\n";

            hMailServer.Account account1 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            Assert.IsTrue(SMTPClientSimulator.StaticSendRaw(account1.Address, account1.Address, messageText));
            string text = POP3Simulator.AssertGetFirstMessageText(account1.Address, "test");
        }
Exemplo n.º 4
0
        public void TestAttachmentRemoval()
        {
            var antiVirusSettings = SingletonProvider <TestSetup> .Instance.GetApp().Settings.AntiVirus;

            antiVirusSettings.EnableAttachmentBlocking = true;

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

            // Send a message to the account.
            string messageText = @"Date: Thu, 03 Jul 2008 22:01:53 +0200\r\n" +
                                 "From: Test <*****@*****.**>\r\n" +
                                 "MIME-Version: 1.0\r\n" +
                                 "To: [email protected]\r\n" +
                                 "Subject: test\r\n" +
                                 "Content-Type: multipart/mixed;\r\n" +
                                 "  boundary=\"------------050908050500020808050006\"\r\n" +
                                 "\r\n" +
                                 "This is a multi-part message in MIME format.\r\n" +
                                 "--------------050908050500020808050006\r\n" +
                                 "Content-Type: text/plain; charset=ISO-8859-1; format=flowed\r\n" +
                                 "Content-Transfer-Encoding: 7bit\r\n" +
                                 "\r\n" +
                                 "Test\r\n" +
                                 "\r\n" +
                                 "--------------050908050500020808050006\r\n" +
                                 "Content-Type: text/plain;\r\n" +
                                 " name=\"AUTOEXEC.BAT\"\r\n" +
                                 "Content-Transfer-Encoding: base64\r\n" +
                                 "Content-Disposition: inline;\r\n" +
                                 " filename=\"AUTOEXEC.BAT\"\r\n" +
                                 "\r\n" +
                                 "\r\n" +
                                 "--------------050908050500020808050006--\r\n";

            SMTPClientSimulator.StaticSendRaw("*****@*****.**", "*****@*****.**", messageText);

            Message message = TestSetup.AssertRetrieveFirstMessage(account1.IMAPFolders.get_ItemByName("INBOX"));

            CustomAssert.AreEqual(1, message.Attachments.Count);
            CustomAssert.AreEqual("AUTOEXEC.BAT.txt", message.Attachments[0].Filename);

            string tempFile = Path.GetTempFileName();

            message.Attachments[0].SaveAs(tempFile);
            string contents = File.ReadAllText(tempFile);

            string removedMessage =
                SingletonProvider <TestSetup> .Instance.GetApp().Settings.ServerMessages.get_ItemByName(
                    "ATTACHMENT_REMOVED").Text;

            removedMessage = removedMessage.Replace("%MACRO_FILE%",
                                                    message.Attachments[0].Filename.Substring(0,
                                                                                              message.Attachments[0].
                                                                                              Filename.Length - 4));

            CustomAssert.IsTrue(contents.Contains(removedMessage));
            File.Delete(tempFile);
        }
Exemplo n.º 5
0
        public void TestParseMultipartNoBody()
        {
            Account account = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string body = TestSetup.GetResource("Messages.MultipartMessageWithNoMainBodyText.txt");

            SMTPClientSimulator.StaticSendRaw(account.Address, account.Address, body);

            POP3ClientSimulator.AssertMessageCount(account.Address, "test", 1);

            var    imapSim = new IMAPClientSimulator("*****@*****.**", "test", "INBOX");
            string result  = imapSim.Fetch("1 (BODY.PEEK[HEADER] BODY.PEEK[TEXT])");

            imapSim.Logout();
        }
Exemplo n.º 6
0
        public void TestDuplicateMessageIDs()
        {
            Account oAccount1 = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string content = "SomeHeader: Text" + Environment.NewLine +
                             "Message-Id: <200903121212246.SM01264@server03>" + Environment.NewLine +
                             "" + Environment.NewLine +
                             "Test";

            SMTPClientSimulator.StaticSendRaw("*****@*****.**", "*****@*****.**", content);

            string test = POP3ClientSimulator.AssertGetFirstMessageText("*****@*****.**", "test");

            CustomAssert.IsTrue(test.Contains("Message-Id"));
            CustomAssert.IsFalse(test.Contains("Message-ID"));
        }
Exemplo n.º 7
0
        public void TestFetchCharsetInQuotesWithoutQuotesWithSpace()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            SMTPClientSimulator.StaticSendRaw(account.Address, account.Address,
                                              "From: [email protected]\r\n" +
                                              "Content-Type: text/plain; charset = iso-8859-1 \r\n" +
                                              "\r\n" +
                                              "Test\r\n");

            IMAPSimulator.AssertMessageCount(account.Address, "test", "Inbox", 1);

            IMAPSimulator sim    = new IMAPSimulator(account.Address, "test", "Inbox");
            string        result = sim.Fetch("1 BODYSTRUCTURE");

            sim.Disconnect();

            Assert.IsTrue(result.Contains("(\"CHARSET\" \"iso-8859-1\")"), result);
        }
Exemplo n.º 8
0
        public void TestDecodeSpecificMessage()
        {
            string message = "Return-Path:" + Environment.NewLine +
                             "Received: from host ([1.2.3.4])" + Environment.NewLine +
                             "X-Facebook: from zuckmail" + Environment.NewLine +
                             "by localhost.localdomain with local (ZuckMail);" + Environment.NewLine +
                             "Date: Wed, 3 Dec 2008 06:14:37 -0800" + Environment.NewLine +
                             "To: [email protected]" + Environment.NewLine +
                             "From: Facebook" + Environment.NewLine +
                             "Reply-to: Facebook" + Environment.NewLine +
                             "Subject: =?UTF-8?Q?V=C3=A4nligen_=C3=A5terst=C3=A4ll_dina_inst=C3=A4llningar_f=C3?=" +
                             Environment.NewLine +
                             "    =?UTF-8?Q?=B6r_meddelanden_via_e-post.?=" + Environment.NewLine +
                             "Message-ID:" + Environment.NewLine +
                             "X-Priority: 3" + Environment.NewLine +
                             "X-Mailer: ZuckMail [version 1.00]" + Environment.NewLine +
                             "Errors-To: [email protected]" + Environment.NewLine +
                             "MIME-Version: 1.0" + Environment.NewLine +
                             "Content-Type: text/plain; charset=\"UTF-8\"" + Environment.NewLine +
                             "Content-Transfer-Encoding: quoted-printable" + Environment.NewLine +
                             "" + Environment.NewLine +
                             "Dina inst=C3=A4llningar f=C3=B6r meddelanden via e-post har tyv=C3=A4rr g=" +
                             Environment.NewLine +
                             "=C3=A5tt f=C3=B6rlorade. Vi beklagar det intr=C3=A4ffade.G=C3=" + Environment.NewLine +
                             "=A5 till http://www.facebook.com/editaccount.php?notifications f=C3=B6r a=" +
                             Environment.NewLine +
                             "tt =C3=A5terst=C3=A4lla dina inst=C3=A4llningar.Tack!Facebook-grupp=" +
                             Environment.NewLine +
                             "en." + Environment.NewLine;

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

            SMTPClientSimulator.StaticSendRaw("*****@*****.**", account.Address, message);

            POP3ClientSimulator.AssertMessageCount(account.Address, "test", 1);

            hMailServer.Message apiMessage = account.Messages[0];

            CustomAssert.AreEqual("Vänligen återställ dina inställningar för meddelanden via e-post.", apiMessage.Subject);
            CustomAssert.IsTrue(
                apiMessage.Body.StartsWith("Dina inställningar för meddelanden via e-post har tyvärr gått förlorade."));
        }
Exemplo n.º 9
0
        public void TestSearchLargeBody()
        {
            Account account = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            var body = new StringBuilder();

            body.AppendLine("From: [email protected]");
            body.AppendLine("Subject: Test");
            body.AppendLine();
            for (int i = 0; i < 20000; i++) // One megabye body.
            {
                body.AppendLine("12345678901234567890123456789012345678901234567890");
            }
            body.AppendLine("TestString");
            body.AppendLine();

            SMTPClientSimulator.StaticSendRaw(account.Address, account.Address, body.ToString());

            POP3ClientSimulator.AssertMessageCount(account.Address, "test", 1);

            var oSimulator = new IMAPClientSimulator();

            CustomAssert.IsTrue(oSimulator.ConnectAndLogon(account.Address, "test"));
            CustomAssert.IsTrue(oSimulator.SelectFolder("INBOX"));
            string result = oSimulator.Search("CHARSET UTF-8 ALL TEXT InvalidText");

            CustomAssert.AreEqual("", result);

            result = oSimulator.Search("CHARSET UTF-8 ALL TEXT TestStringA");
            CustomAssert.AreEqual("", result);

            result = oSimulator.Search("CHARSET UTF-8 ALL TEXT TestString");
            CustomAssert.AreEqual("1", result);

            result = oSimulator.Search("CHARSET UTF-8 ALL TEXT TestStr");
            CustomAssert.AreEqual("1", result);

            result = oSimulator.Search("UNDELETED BODY \"TestString\"");
            CustomAssert.AreEqual("1", result);

            oSimulator.Close();
        }
        public void TestInvalidBodyHashMark()
        {
            _antiSpam.SpamDeleteThreshold          = 1000;
            _antiSpam.SpamMarkThreshold            = 5;
            _antiSpam.DKIMVerificationEnabled      = true;
            _antiSpam.DKIMVerificationFailureScore = 6;

            string messageText = @"DKIM-Signature: v=1; a=rsa-sha1; c=simple; d=messiah.edu; h=from:to" + "\r\n" +
                                 "	:subject:date; s=test3; [email protected]; bh=OW2otvzd7V2TO8"+ "\r\n" +
                                 "	w056SjbYRFCa0=; b=Vfr8HgUlyVf1ZaRVMV8VJNSDXn7f1j2N/rFM4PPmYIC2GD"+ "\r\n" +
                                 "	pSelCRrdA979Buuu/Mmx9FTWoZJBL+s5tafFM8bw=="+ "\r\n" +
                                 "Received: from x.y.test" + "\r\n" +
                                 "   by example.net" + "\r\n" +
                                 "   via TCP" + "\r\n" +
                                 "   with ESMTP" + "\r\n" +
                                 "   id ABC12345" + "\r\n" +
                                 "   for <*****@*****.**>;  21 Nov 1997 10:05:43 -0600" + "\r\n" +
                                 "Received: from machine.example by x.y.test; 21 Nov 1997 10:01:22 -0600" + "\r\n" +
                                 "From: Jason Long <*****@*****.**>" + "\r\n" +
                                 "To: Nobody <*****@*****.**>" + "\r\n" +
                                 "Subject: dkim test (i= uses quoted-printable)" + "\r\n" +
                                 "Date: Wed, 9 Apr 2008 09:11:00 -0500" + "\r\n" +
                                 "" + "\r\n" +
                                 "Should pass." + "\r\n" +
                                 "" + "\r\n" +
                                 "This is a test" + "\r\n" +
                                 "  More lines here" + "\r\n" +
                                 "" + "\r\n" +
                                 "Blah  blah  blah" + "\r\n" +
                                 "" + "\r\n" +
                                 "" + "\r\n" +
                                 "" + "\r\n" +
                                 "" + "\r\n";

            hMailServer.Account account1 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            Assert.IsTrue(SMTPClientSimulator.StaticSendRaw(account1.Address, account1.Address, messageText));
            string text = POP3Simulator.AssertGetFirstMessageText(account1.Address, "test");

            Assert.IsTrue(text.Contains("Rejected by DKIM. - (Score: 6)"));
        }
Exemplo n.º 11
0
        public void TestSearchUTF8()
        {
            Account account = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string body = TestSetup.GetResource("Messages.MessageContainingGreekAndJapanese.txt");

            SMTPClientSimulator.StaticSendRaw(account.Address, account.Address, body);

            POP3ClientSimulator.AssertMessageCount(account.Address, "test", 1);

            var oSimulator = new IMAPClientSimulator();

            CustomAssert.IsTrue(oSimulator.ConnectAndLogon(account.Address, "test"));
            CustomAssert.IsTrue(oSimulator.SelectFolder("INBOX"));

            string result = oSimulator.Search("CHARSET UTF-8 ALL TEXT GRΣΣK");

            CustomAssert.AreEqual("1", result);

            result = oSimulator.Search("CHARSET UTF-8 ALL TEXT ÅÄÖ");
            CustomAssert.AreEqual("1", result);

            result = oSimulator.Search("CHARSET UTF-8 ALL TEXT 標準語標準語");
            CustomAssert.AreEqual("1", result);

            result = oSimulator.Search("CHARSET UTF-8 ALL TEXT ßEßEß");
            CustomAssert.AreEqual("1", result);

            result = oSimulator.Search("CHARSET UTF-8 ALL TEXT ÅÅÅ");
            CustomAssert.AreEqual("", result);

            result = oSimulator.Search("CHARSET UTF-8 ALL TEXT GREEK");
            CustomAssert.AreEqual("", result);

            result = oSimulator.Search("CHARSET UTF-8 ALL TEXT ßEEEß");
            CustomAssert.AreEqual("", result);

            result = oSimulator.Search("CHARSET UTF-8 ALL TEXT 標準語標語語");
            CustomAssert.AreEqual("", result);
        }
Exemplo n.º 12
0
        public void TestAddTextToEmptyBody()
        {
            Account account1 = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            // Send a message to the account.
            string messageText = @"Date: Thu, 03 Jul 2008 22:01:53 +0200\r\n" +
                                 "From: Test <*****@*****.**>\r\n" +
                                 "MIME-Version: 1.0\r\n" +
                                 "To: [email protected]\r\n" +
                                 "Subject: test\r\n" +
                                 "Content-Type: multipart/mixed;\r\n" +
                                 "  boundary=\"------------050908050500020808050006\"\r\n" +
                                 "\r\n" +
                                 "This is a multi-part message in MIME format.\r\n" +
                                 "--------------050908050500020808050006\r\n" +
                                 "Content-Type: text/plain; charset=ISO-8859-1; format=flowed\r\n" +
                                 "Content-Transfer-Encoding: 7bit\r\n" +
                                 "\r\n" +
                                 "Test\r\n" +
                                 "\r\n" +
                                 "--------------050908050500020808050006\r\n" +
                                 "Content-Type: text/plain;\r\n" +
                                 " name=\"AUTOEXEC.BAT\"\r\n" +
                                 "Content-Transfer-Encoding: base64\r\n" +
                                 "Content-Disposition: inline;\r\n" +
                                 " filename=\"AUTOEXEC.BAT\"\r\n" +
                                 "\r\n" +
                                 "\r\n" +
                                 "--------------050908050500020808050006--\r\n";

            SMTPClientSimulator.StaticSendRaw("*****@*****.**", "*****@*****.**", messageText);

            hMailServer.Message message =
                TestSetup.AssertRetrieveFirstMessage(account1.IMAPFolders.get_ItemByName("INBOX"));
            CustomAssert.AreEqual(1, message.Attachments.Count);
            CustomAssert.AreEqual("AUTOEXEC.BAT", message.Attachments[0].Filename);
        }