コード例 #1
0
ファイル: API.Message.cs プロジェクト: radtek/hMailServer
        public void TestMailCreationUnicodeAndAttachment()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string filename = Path.Combine(Path.GetTempPath(), "dummy.txt");

            File.WriteAllText(filename, "tjena moss");

            hMailServer.Message message = new hMailServer.Message();
            message.AddRecipient("", account.Address);
            message.Charset = "utf-8";
            message.Attachments.Add(filename);
            // may cause an assert.
            message.HTMLBody = "Test of message... 日本語";
            message.Body     = "Test of message... 日本語";
            message.Save();

            string messageText = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");


            int    headerEnd = messageText.IndexOf("\r\n\r\n");
            string header    = messageText.Substring(0, headerEnd);

            Assert.IsTrue(header.Contains("Content-Type: multipart/mixed; charset=\"utf-8\""));

            File.Delete(filename);
        }
コード例 #2
0
ファイル: API.Unicode.cs プロジェクト: radtek/hMailServer
        public void TestModifyBodyWithExistingAttachments()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string swedish        = "abc.zip";
            string attachmentName = swedish + ".zip";
            string filename       = Path.Combine(Path.GetTempPath(), attachmentName);

            File.WriteAllText(filename, swedish);


            hMailServer.Message message = new hMailServer.Message();
            message.AddRecipient("test", account.Address);
            message.Attachments.Add(filename);
            message.From        = swedish;
            message.FromAddress = account.Address;
            message.Subject     = swedish;
            message.Body        = "";
            message.Save();

            Utilities.AssertMessageExistsInFolder(account.IMAPFolders[0], 1);

            hMailServer.Message downloadedMessage = account.IMAPFolders[0].Messages[0];

            downloadedMessage.Body = "Test";
            downloadedMessage.Save();
        }
コード例 #3
0
ファイル: API.Unicode.cs プロジェクト: radtek/hMailServer
        public void TestJapaneseAttachments()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string attachmentName = "本本本.zip";

            string filename = Path.Combine(Path.GetTempPath(), attachmentName);

            File.WriteAllText(filename, "tjena moss");

            hMailServer.Message message = new hMailServer.Message();
            message.AddRecipient("test", account.Address);
            message.From        = "Test";
            message.FromAddress = account.Address;
            message.Body        = "hejsan";
            message.Attachments.Add(filename);
            message.Save();

            Utilities.AssertMessageExistsInFolder(account.IMAPFolders[0], 1);

            hMailServer.Message downloadedMessage = account.IMAPFolders[0].Messages[0];
            Assert.AreNotEqual(0, downloadedMessage.Attachments.Count);
            hMailServer.Attachment attachment = downloadedMessage.Attachments[0];
            Assert.AreEqual(attachmentName, attachment.Filename);
        }
コード例 #4
0
ファイル: API.Message.cs プロジェクト: radtek/hMailServer
        public void TestAddBodyAfterAttachment()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string filename = Path.Combine(Path.GetTempPath(), "dummy.txt");

            File.WriteAllText(filename, "tjena moss");

            hMailServer.Message message = new hMailServer.Message();
            message.AddRecipient("", account.Address);
            message.Attachments.Add(filename);
            message.Body = "Hello";
            message.Save();

            string messageText = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

            int    headerEnd = messageText.IndexOf("\r\n\r\n");
            string header    = messageText.Substring(0, headerEnd);

            Assert.IsTrue(header.Contains("Content-Type: multipart/mixed;"));
            Assert.IsTrue(messageText.Contains("Hello"));
            Assert.IsTrue(messageText.Contains("dummy.txt"));

            File.Delete(filename);
        }
コード例 #5
0
ファイル: API.Unicode.cs プロジェクト: radtek/hMailServer
        public void TestSwedishAndChineseCombination()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string swedishAndChinese = "ÅÄÖ汉语";
            string attachmentName    = swedishAndChinese + ".zip";

            string filename = Path.Combine(Path.GetTempPath(), attachmentName);

            File.WriteAllText(filename, swedishAndChinese);

            hMailServer.Message message = new hMailServer.Message();
            message.AddRecipient("test", account.Address);
            message.From        = "Test";
            message.FromAddress = account.Address;
            message.Body        = swedishAndChinese;
            message.Attachments.Add(filename);
            message.Save();

            Utilities.AssertMessageExistsInFolder(account.IMAPFolders[0], 1);

            hMailServer.Message downloadedMessage = account.IMAPFolders[0].Messages[0];
            Assert.AreNotEqual(0, downloadedMessage.Attachments.Count);
            hMailServer.Attachment attachment = downloadedMessage.Attachments[0];
            Assert.AreEqual(attachmentName, attachment.Filename);

            Assert.AreEqual(swedishAndChinese + Environment.NewLine, downloadedMessage.Body);
        }
コード例 #6
0
ファイル: API.Unicode.cs プロジェクト: radtek/hMailServer
        public void TestEncodingOfStringIncludingSpace()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            hMailServer.Message message = new hMailServer.Message();
            message.AddRecipient("test", account.Address);
            message.From        = "Test";
            message.FromAddress = account.Address;
            message.Subject     = "test mit encoding und deutc ü...";
            message.Body        = "Test";
            message.Save();

            Utilities.AssertMessageExistsInFolder(account.IMAPFolders[0], 1);

            string messageText = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

            string [] lines = messageText.Split(Environment.NewLine.ToCharArray());

            foreach (string line in lines)
            {
                if (line.ToLower().StartsWith("subject: "))
                {
                    string subject = line.Substring("subject: ".Length + 1);

                    // encoded part should not contain space.
                    Assert.IsFalse(subject.Contains(" "));

                    break;
                }
            }
        }
コード例 #7
0
ファイル: IMAP.Fetch.cs プロジェクト: radtek/hMailServer
        public void TestBodyStructureWithNonLatinCharacter()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string attachmentName = "本本本.zip";

            string filename = Path.Combine(Path.GetTempPath(), attachmentName);

            File.WriteAllText(filename, "tjena moss");

            hMailServer.Message message = new hMailServer.Message();
            message.Charset = "utf-8";
            message.AddRecipient("test", account.Address);
            message.From        = "Test";
            message.FromAddress = account.Address;
            message.Body        = "hejsan";
            message.Attachments.Add(filename);
            message.Save();

            Utilities.AssertMessageExistsInFolder(account.IMAPFolders[0], 1);

            IMAPSimulator oSimulator = new IMAPSimulator();

            oSimulator.ConnectAndLogon(account.Address, "test");
            oSimulator.SelectFolder("INBOX");
            string result = oSimulator.Fetch("1 BODYSTRUCTURE");

            oSimulator.Disconnect();

            // utf-8 representation of 本本本.zip:
            Assert.IsTrue(result.Contains("=?utf-8?B?5pys5pys5pys?=.zip"));
        }
コード例 #8
0
ファイル: API.Unicode.cs プロジェクト: radtek/hMailServer
        public void SwedishCharactersInBody()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            hMailServer.Message message = new hMailServer.Message();
            message.AddRecipient("Ö", account.Address);
            message.Charset = "utf-8";
            message.Body    = "Test ÅÄÖ Test.";

            string body = message.Body;

            Assert.IsTrue(body.Contains("Test ÅÄÖ Test."));
        }
コード例 #9
0
        private void SendMessage(string subject, string body, string to, string cc)
        {
            hMailServer.Message message = new hMailServer.Message();

            message.Charset = "UTF-8";
            message.AddRecipient("test", "meta'*****@*****.**");
            message.From        = "Test";
            message.FromAddress = "meta'*****@*****.**";
            message.Subject     = subject;
            message.set_HeaderValue("To", to);
            message.set_HeaderValue("cc", cc);
            message.Body = body;
            message.Save();
        }
コード例 #10
0
ファイル: API.Unicode.cs プロジェクト: radtek/hMailServer
        public void SingleLatinCharacterRecipient()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            hMailServer.Message message = new hMailServer.Message();
            message.AddRecipient("Ö", account.Address);
            message.Charset = "utf-8";
            message.Body    = "Test body.";
            message.Save();

            string messageText = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

            Assert.IsTrue(messageText.Contains("To: \"=?utf-8?B?w5Y=?=\" <*****@*****.**>"));
        }
コード例 #11
0
ファイル: API.Message.cs プロジェクト: radtek/hMailServer
        public void TestMailCreationUnicodeBodyAndHtml()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            hMailServer.Message message = new hMailServer.Message();
            message.AddRecipient("", account.Address);
            message.Charset  = "utf-8";
            message.Body     = "Test of message... 日本語";
            message.HTMLBody = "Test of message... 日本語";
            message.Save();

            string messageText = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

            Assert.IsTrue(messageText.Contains("Content-Type: text/html; charset=\"utf-8\""));
            Assert.IsTrue(messageText.Contains("Content-Type: text/plain; charset=\"utf-8\""));
        }
コード例 #12
0
ファイル: API.Message.cs プロジェクト: radtek/hMailServer
        public void TestMailCreationHTML()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            hMailServer.Message message = new hMailServer.Message();
            message.AddRecipient("", account.Address);
            message.HTMLBody = "Hello";
            message.Save();

            string messageText = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

            int    headerEnd = messageText.IndexOf("\r\n\r\n");
            string header    = messageText.Substring(0, headerEnd);

            Assert.IsTrue(header.Contains("Content-Type: text/html; charset=\"utf-8\""));
            Assert.IsTrue(header.Contains("Content-Transfer-Encoding: quoted-printable"));
            Assert.IsTrue(messageText.Contains("Hello"));
        }
コード例 #13
0
ファイル: API.Unicode.cs プロジェクト: radtek/hMailServer
        public void NonLatinCharactersInRecipientNameResultsInBoxesInThunderbird()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            hMailServer.Message message = new hMailServer.Message();
            //message.AddRecipient("Тестов Тест ТестостероновичТестостероновичТестостероновичТестостероновичТестостероновичТестостероновичТестостероновичТестостероновичТестостероновичТестостероновичТестостероновичТестостеронович", account.Address);
            message.AddRecipient("ТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероно", account.Address);
            message.Subject = "Test";
            message.Charset = "utf-8";
            message.Body    = "Test body.";
            message.Save();

            string messageText = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

            // Important:
            //   RFC 2047: http://www.faqs.org/rfcs/rfc2047.html
            //   The notation of RFC 822 is used, with the exception that white space
            //   characters MUST NOT appear between components of an 'encoded-word'.
            //
            //   Also, there should be a space separating the encoded word with the following
            //   non-encoded word.


            string match =
                "To: \"=?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
                " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
                " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
                " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
                " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
                " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
                " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
                " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
                " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
                " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
                " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
                " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
                " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
                " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
                " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
                " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\" <*****@*****.**>";


            Assert.IsTrue(messageText.Contains(match));
        }
コード例 #14
0
ファイル: API.Unicode.cs プロジェクト: radtek/hMailServer
        public void TestDanishSubject()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string croatianAndDanish = "ʒʥʨPiskefløde";

            hMailServer.Message message = new hMailServer.Message();
            message.AddRecipient("test", account.Address);
            message.From        = "Test";
            message.FromAddress = account.Address;
            message.Subject     = croatianAndDanish;
            message.Body        = "hej";
            message.Save();

            Utilities.AssertMessageExistsInFolder(account.IMAPFolders[0], 1);

            hMailServer.Message downloadedMessage = account.IMAPFolders[0].Messages[0];
            Assert.AreEqual(croatianAndDanish, downloadedMessage.Subject);
        }
コード例 #15
0
ファイル: API.Unicode.cs プロジェクト: nberardi/hMailServer
        public void NonLatinCharactersInRecipientNameResultsInBoxesInThunderbird()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             hMailServer.Message message = new hMailServer.Message();
             //message.AddRecipient("Тестов Тест ТестостероновичТестостероновичТестостероновичТестостероновичТестостероновичТестостероновичТестостероновичТестостероновичТестостероновичТестостероновичТестостероновичТестостеронович", account.Address);
             message.AddRecipient("ТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероноТестовТестТестостероно", account.Address);
             message.Subject = "Test";
             message.Charset = "utf-8";
             message.Body = "Test body.";
             message.Save();

             string messageText = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

             // Important:
             //   RFC 2047: http://www.faqs.org/rfcs/rfc2047.html
             //   The notation of RFC 822 is used, with the exception that white space
             //   characters MUST NOT appear between components of an 'encoded-word'.
             //
             //   Also, there should be a space separating the encoded word with the following
             //   non-encoded word.

              string match =
              "To: \"=?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n"+
             " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
             " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
             " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
             " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
             " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
             " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
             " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
             " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
             " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
             " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
             " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
             " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
             " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
             " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\r\n" +
             " =?utf-8?B?0KLQtdGB0YLQvtCy0KLQtdGB0YLQotC10YHRgtC+0YHRgtC10YDQvtC90L4=?=\" <*****@*****.**>";

             Assert.IsTrue(messageText.Contains(match));
        }
コード例 #16
0
ファイル: API.Unicode.cs プロジェクト: radtek/hMailServer
        public void TestEncodeWord()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string croatianAndDanish = "ʒʥʨPiskefløde";

            hMailServer.Message message = new hMailServer.Message();
            message.Subject = croatianAndDanish;
            message.AddRecipient("", account.Address);
            message.Save();

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

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

            Assert.AreEqual(apiMessage.Subject, croatianAndDanish);
            string fileContents = File.ReadAllText(apiMessage.Filename);

            Assert.IsFalse(fileContents.Contains(croatianAndDanish));
        }
コード例 #17
0
ファイル: API.Message.cs プロジェクト: radtek/hMailServer
        public void TestMailCreationHTMLAndPlainTextReverse()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            hMailServer.Message message = new hMailServer.Message();
            message.AddRecipient("", account.Address);
            message.Body     = "PlainTextBody";
            message.HTMLBody = "HTMLBody";
            message.Save();

            string messageText = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

            int    headerEnd = messageText.IndexOf("\r\n\r\n");
            string header    = messageText.Substring(0, headerEnd);

            Assert.IsTrue(header.Contains("Content-Type: multipart/alternative"));
            Assert.IsFalse(header.Contains("Content-Transfer-Encoding: quoted-printable"));
            Assert.IsTrue(messageText.Contains("PlainTextBody"));
            Assert.IsTrue(messageText.Contains("HTMLBody"));
        }
コード例 #18
0
ファイル: API.Unicode.cs プロジェクト: radtek/hMailServer
        public void TestMultipleLanguages()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            string manyLanguages = "中文åäöん文t͡ɬɪŋ";

            hMailServer.Message message = new hMailServer.Message();
            message.AddRecipient("test", account.Address);
            message.From        = manyLanguages;
            message.FromAddress = account.Address;
            message.Subject     = manyLanguages;
            message.Body        = manyLanguages;
            message.Save();

            Utilities.AssertMessageExistsInFolder(account.IMAPFolders[0], 1);

            hMailServer.Message downloadedMessage = account.IMAPFolders[0].Messages[0];
            Assert.AreEqual(manyLanguages, downloadedMessage.Subject);
            Assert.AreEqual(manyLanguages, downloadedMessage.From);
            Assert.AreEqual(manyLanguages + Environment.NewLine, downloadedMessage.Body);
        }
コード例 #19
0
ファイル: API.cs プロジェクト: radtek/hMailServer
        public void TestSendMessage()
        {
            hMailServer.Account oAccount1 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            // Send a message to the account.
            hMailServer.Message oMessage = new hMailServer.Message();

            Assert.AreEqual(0, oMessage.State);

            oMessage.AddRecipient("Martin", oAccount1.Address);
            oMessage.Body    = "Välkommen till verkligheten";
            oMessage.Subject = "Hej";
            oMessage.Save();

            Assert.AreEqual(1, oMessage.State);

            // Check that the message exists
            string message = POP3Simulator.AssertGetFirstMessageText(oAccount1.Address, "test");

            Assert.IsNotEmpty(message);
            Assert.Less(0, message.IndexOf("Hej"));
        }
コード例 #20
0
ファイル: API.Unicode.cs プロジェクト: radtek/hMailServer
        public void TestMostlyLatinCharacters()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            hMailServer.Message message = new hMailServer.Message();
            message.AddRecipient("Test Recipient: Тест", account.Address);
            message.Subject = "Test Subject: Тест";
            message.Charset = "utf-8";
            message.Body    = "Test body.";
            message.Save();

            string messageText = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

            // Important:
            //   RFC 2047: http://www.faqs.org/rfcs/rfc2047.html
            //   The notation of RFC 822 is used, with the exception that white space
            //   characters MUST NOT appear between components of an 'encoded-word'.
            //
            //   Also, there should be a space separating the encoded word with the following
            //   non-encoded word.
            Assert.IsTrue(messageText.Contains("To: \"=?utf-8?B?VGVzdCBSZWNpcGllbnQ6INCi0LXRgdGC?=\" <*****@*****.**>"));
        }
コード例 #21
0
ファイル: API.Message.cs プロジェクト: nberardi/hMailServer
        public void TestAddBodyAfterAttachment()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             string filename = Path.Combine(Path.GetTempPath(), "dummy.txt");
             File.WriteAllText(filename, "tjena moss");

             hMailServer.Message message = new hMailServer.Message();
             message.AddRecipient("", account.Address);
             message.Attachments.Add(filename);
             message.Body = "Hello";
             message.Save();

             string messageText = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

             int headerEnd = messageText.IndexOf("\r\n\r\n");
             string header = messageText.Substring(0, headerEnd);

             Assert.IsTrue(header.Contains("Content-Type: multipart/mixed;"));
             Assert.IsTrue(messageText.Contains("Hello"));
             Assert.IsTrue(messageText.Contains("dummy.txt"));

             File.Delete(filename);
        }
コード例 #22
0
ファイル: API.Unicode.cs プロジェクト: nberardi/hMailServer
        public void TestModifyBodyWithExistingAttachments()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             string swedish = "abc.zip";
             string attachmentName = swedish + ".zip";
             string filename = Path.Combine(Path.GetTempPath(), attachmentName);
             File.WriteAllText(filename, swedish);

             hMailServer.Message message = new hMailServer.Message();
             message.AddRecipient("test", account.Address);
             message.Attachments.Add(filename);
             message.From = swedish;
             message.FromAddress = account.Address;
             message.Subject = swedish;
             message.Body = "";
             message.Save();

             Utilities.AssertMessageExistsInFolder(account.IMAPFolders[0], 1);

             hMailServer.Message downloadedMessage = account.IMAPFolders[0].Messages[0];

             downloadedMessage.Body = "Test";
             downloadedMessage.Save();
        }
コード例 #23
0
ファイル: API.Unicode.cs プロジェクト: nberardi/hMailServer
        public void TestJapaneseAttachments()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             string attachmentName = "本本本.zip";

             string filename = Path.Combine(Path.GetTempPath(), attachmentName);
             File.WriteAllText(filename, "tjena moss");

             hMailServer.Message message = new hMailServer.Message();
             message.AddRecipient("test", account.Address);
             message.From = "Test";
             message.FromAddress = account.Address;
             message.Body = "hejsan";
             message.Attachments.Add(filename);
             message.Save();

             Utilities.AssertMessageExistsInFolder(account.IMAPFolders[0], 1);

             hMailServer.Message downloadedMessage = account.IMAPFolders[0].Messages[0];
             Assert.AreNotEqual(0, downloadedMessage.Attachments.Count);
             hMailServer.Attachment attachment = downloadedMessage.Attachments[0];
             Assert.AreEqual(attachmentName, attachment.Filename);
        }
コード例 #24
0
        private void SendMessage(string subject, string body, string to, string cc)
        {
            hMailServer.Message message = new hMailServer.Message();

             message.Charset = "UTF-8";
             message.AddRecipient("test", "meta'*****@*****.**");
             message.From = "Test";
             message.FromAddress = "meta'*****@*****.**";
             message.Subject = subject;
             message.set_HeaderValue("To", to);
             message.set_HeaderValue("cc", cc);
             message.Body = body;
             message.Save();
        }
コード例 #25
0
ファイル: API.Unicode.cs プロジェクト: nberardi/hMailServer
        public void TestEncodingOfStringIncludingSpace()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             hMailServer.Message message = new hMailServer.Message();
             message.AddRecipient("test", account.Address);
             message.From = "Test";
             message.FromAddress = account.Address;
             message.Subject = "test mit encoding und deutc ü...";
             message.Body = "Test";
             message.Save();

             Utilities.AssertMessageExistsInFolder(account.IMAPFolders[0], 1);

             string messageText = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

             string [] lines = messageText.Split(Environment.NewLine.ToCharArray());

             foreach (string line in lines)
             {
            if (line.ToLower().StartsWith("subject: "))
            {
               string subject = line.Substring("subject: ".Length + 1);

               // encoded part should not contain space.
               Assert.IsFalse(subject.Contains(" "));

               break;
            }

             }
        }
コード例 #26
0
ファイル: API.Unicode.cs プロジェクト: nberardi/hMailServer
        public void TestEncodeWord()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

              string croatianAndDanish = "ʒʥʨPiskefløde";
              hMailServer.Message message = new hMailServer.Message();
              message.Subject = croatianAndDanish;
              message.AddRecipient("", account.Address);
              message.Save();

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

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

              Assert.AreEqual(apiMessage.Subject, croatianAndDanish);
              string fileContents = File.ReadAllText(apiMessage.Filename);
              Assert.IsFalse(fileContents.Contains(croatianAndDanish));
        }
コード例 #27
0
ファイル: API.Unicode.cs プロジェクト: nberardi/hMailServer
        public void TestDanishSubject()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             string croatianAndDanish = "ʒʥʨPiskefløde";

             hMailServer.Message message = new hMailServer.Message();
             message.AddRecipient("test", account.Address);
             message.From = "Test";
             message.FromAddress = account.Address;
             message.Subject = croatianAndDanish;
             message.Body = "hej";
             message.Save();

             Utilities.AssertMessageExistsInFolder(account.IMAPFolders[0], 1);

             hMailServer.Message downloadedMessage = account.IMAPFolders[0].Messages[0];
             Assert.AreEqual(croatianAndDanish, downloadedMessage.Subject);
        }
コード例 #28
0
ファイル: API.Unicode.cs プロジェクト: nberardi/hMailServer
        public void SwedishCharactersInBody()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

              hMailServer.Message message = new hMailServer.Message();
              message.AddRecipient("Ö", account.Address);
              message.Charset = "utf-8";
              message.Body = "Test ÅÄÖ Test.";

              string body = message.Body;
              Assert.IsTrue(body.Contains("Test ÅÄÖ Test."));
        }
コード例 #29
0
ファイル: API.Message.cs プロジェクト: nberardi/hMailServer
        public void TestMailCreationHTMLAndPlainTextReverse()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             hMailServer.Message message = new hMailServer.Message();
             message.AddRecipient("", account.Address);
             message.Body = "PlainTextBody";
             message.HTMLBody = "HTMLBody";
             message.Save();

             string messageText = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

             int headerEnd = messageText.IndexOf("\r\n\r\n");
             string header = messageText.Substring(0, headerEnd);

             Assert.IsTrue(header.Contains("Content-Type: multipart/alternative"));
             Assert.IsFalse(header.Contains("Content-Transfer-Encoding: quoted-printable"));
             Assert.IsTrue(messageText.Contains("PlainTextBody"));
             Assert.IsTrue(messageText.Contains("HTMLBody"));
        }
コード例 #30
0
ファイル: API.Unicode.cs プロジェクト: nberardi/hMailServer
        public void TestSwedishAndChineseCombination()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             string swedishAndChinese = "ÅÄÖ汉语";
             string attachmentName = swedishAndChinese + ".zip";

             string filename = Path.Combine(Path.GetTempPath(), attachmentName);
             File.WriteAllText(filename, swedishAndChinese);

             hMailServer.Message message = new hMailServer.Message();
             message.AddRecipient("test", account.Address);
             message.From = "Test";
             message.FromAddress = account.Address;
             message.Body = swedishAndChinese;
             message.Attachments.Add(filename);
             message.Save();

             Utilities.AssertMessageExistsInFolder(account.IMAPFolders[0], 1);

             hMailServer.Message downloadedMessage = account.IMAPFolders[0].Messages[0];
             Assert.AreNotEqual(0, downloadedMessage.Attachments.Count);
             hMailServer.Attachment attachment = downloadedMessage.Attachments[0];
             Assert.AreEqual(attachmentName, attachment.Filename);

             Assert.AreEqual(swedishAndChinese + Environment.NewLine, downloadedMessage.Body);
        }
コード例 #31
0
ファイル: API.Unicode.cs プロジェクト: nberardi/hMailServer
        public void TestMostlyLatinCharacters()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             hMailServer.Message message = new hMailServer.Message();
             message.AddRecipient("Test Recipient: Тест", account.Address);
             message.Subject = "Test Subject: Тест";
             message.Charset = "utf-8";
             message.Body = "Test body.";
             message.Save();

             string messageText = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

             // Important:
             //   RFC 2047: http://www.faqs.org/rfcs/rfc2047.html
             //   The notation of RFC 822 is used, with the exception that white space
             //   characters MUST NOT appear between components of an 'encoded-word'.
             //
             //   Also, there should be a space separating the encoded word with the following
             //   non-encoded word.
             Assert.IsTrue(messageText.Contains("To: \"=?utf-8?B?VGVzdCBSZWNpcGllbnQ6INCi0LXRgdGC?=\" <*****@*****.**>"));
        }
コード例 #32
0
ファイル: API.Message.cs プロジェクト: nberardi/hMailServer
        public void TestMailCreationUnicodeAndAttachment()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             string filename = Path.Combine(Path.GetTempPath(), "dummy.txt");
             File.WriteAllText(filename, "tjena moss");

             hMailServer.Message message = new hMailServer.Message();
             message.AddRecipient("", account.Address);
             message.Charset = "utf-8";
             message.Attachments.Add(filename);
             // may cause an assert.
             message.HTMLBody = "Test of message... 日本語";
             message.Body = "Test of message... 日本語";
             message.Save();

             string messageText = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

             int headerEnd = messageText.IndexOf("\r\n\r\n");
             string header = messageText.Substring(0, headerEnd);

             Assert.IsTrue(header.Contains("Content-Type: multipart/mixed; charset=\"utf-8\""));

             File.Delete(filename);
        }
コード例 #33
0
ファイル: API.Message.cs プロジェクト: nberardi/hMailServer
        public void TestMailCreationUnicodeBodyAndHtml()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             hMailServer.Message message = new hMailServer.Message();
             message.AddRecipient("", account.Address);
             message.Charset = "utf-8";
             message.Body = "Test of message... 日本語";
             message.HTMLBody = "Test of message... 日本語";
             message.Save();

             string messageText = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

             Assert.IsTrue(messageText.Contains("Content-Type: text/html; charset=\"utf-8\""));
             Assert.IsTrue(messageText.Contains("Content-Type: text/plain; charset=\"utf-8\""));
        }
コード例 #34
0
ファイル: API.Unicode.cs プロジェクト: nberardi/hMailServer
        public void TestMultipleLanguages()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             string manyLanguages = "中文åäöん文t͡ɬɪŋ";

             hMailServer.Message message = new hMailServer.Message();
             message.AddRecipient("test", account.Address);
             message.From = manyLanguages;
             message.FromAddress = account.Address;
             message.Subject = manyLanguages;
             message.Body = manyLanguages;
             message.Save();

             Utilities.AssertMessageExistsInFolder(account.IMAPFolders[0], 1);

             hMailServer.Message downloadedMessage = account.IMAPFolders[0].Messages[0];
             Assert.AreEqual(manyLanguages, downloadedMessage.Subject);
             Assert.AreEqual(manyLanguages, downloadedMessage.From);
             Assert.AreEqual(manyLanguages + Environment.NewLine, downloadedMessage.Body);
        }
コード例 #35
0
ファイル: API.Message.cs プロジェクト: nberardi/hMailServer
        public void TestMailCreationPlainText()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             hMailServer.Message message = new hMailServer.Message();
             message.AddRecipient("", account.Address);
             message.Body = "Hello";
             message.Save();

             string messageText = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

             int headerEnd = messageText.IndexOf("\r\n\r\n");
             string header = messageText.Substring(0, headerEnd);

             Assert.IsTrue(header.Contains("Content-Type: text/plain; charset=\"utf-8\""));
             Assert.IsTrue(header.Contains("Content-Transfer-Encoding: quoted-printable"));
             Assert.IsTrue(messageText.Contains("Hello"));
        }
コード例 #36
0
ファイル: API.Unicode.cs プロジェクト: nberardi/hMailServer
        public void SingleLatinCharacterRecipient()
        {
            hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "*****@*****.**", "test");

             hMailServer.Message message = new hMailServer.Message();
             message.AddRecipient("Ö", account.Address);
             message.Charset = "utf-8";
             message.Body = "Test body.";
             message.Save();

             string messageText = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

             Assert.IsTrue(messageText.Contains("To: \"=?utf-8?B?w5Y=?=\" <*****@*****.**>"));
        }
コード例 #37
0
 public void AddRecipient(string sName, string sAddress)
 {
     _object.AddRecipient(sName, sAddress);
 }