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); }
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(); }
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); }
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); }
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); }
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; } } }
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")); }
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.")); }
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(); }
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=?=\" <*****@*****.**>")); }
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\"")); }
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")); }
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)); }
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); }
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)); }
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)); }
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")); }
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); }
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")); }
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?=\" <*****@*****.**>")); }
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); }
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(); }
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); }
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; } } }
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)); }
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); }
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.")); }
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")); }
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); }
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?=\" <*****@*****.**>")); }
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); }
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\"")); }
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); }
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")); }
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=?=\" <*****@*****.**>")); }
public void AddRecipient(string sName, string sAddress) { _object.AddRecipient(sName, sAddress); }