public void TestAutoReply() { // Create a test account // Fetch the default domain hMailServer.Account oAccount1 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, Utilities.RandomString() + "@test.com", "test"); hMailServer.Account oAccount2 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, Utilities.RandomString() + "@test.com", "test"); oAccount2.VacationMessageIsOn = true; oAccount2.VacationMessage = "I'm on vacation"; oAccount2.VacationSubject = "Out of office!"; oAccount2.Save(); // Send 2 messages to this account. SMTPClientSimulator oSMTP = new SMTPClientSimulator(); oSMTP.Send(oAccount1.Address, oAccount2.Address, "Test message", "This is the body"); POP3Simulator oPOP3 = new POP3Simulator(); POP3Simulator.AssertMessageCount(oAccount1.Address, "test", 1); POP3Simulator.AssertMessageCount(oAccount2.Address, "test", 1); string s = oPOP3.GetFirstMessageText(oAccount1.Address, "test"); if (s.IndexOf("Out of office!") < 0) { throw new Exception("ERROR - Auto reply subject not set properly."); } oAccount2.VacationMessageIsOn = false; oAccount2.Save(); oAccount2.VacationSubject = ""; oAccount2.VacationMessageIsOn = true; oAccount2.Save(); // Send another oSMTP.Send(oAccount1.Address, oAccount2.Address, "Test message", "This is the body"); POP3Simulator.AssertMessageCount(oAccount2.Address, "test", 2); POP3Simulator.AssertMessageCount(oAccount1.Address, "test", 1); s = oPOP3.GetFirstMessageText(oAccount1.Address, "test"); if (s.ToLower().IndexOf("re: test message") < 0) { throw new Exception("ERROR - Auto reply subject not set properly."); } oAccount2.VacationMessageIsOn = false; oAccount2.Save(); }
public void TestDomainAdminAccessOtherDomain() { hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test"); account.AdminLevel = hMailServer.eAdminLevel.hAdminLevelDomainAdmin; account.Save(); SingletonProvider <Utilities> .Instance.AddDomain("example.com"); hMailServer.Application newApplication = new hMailServer.Application(); newApplication.Authenticate("*****@*****.**", "test"); Assert.AreEqual(1, newApplication.Domains.Count); hMailServer.Domains domains = SingletonProvider <Utilities> .Instance.GetApp().Domains; Assert.AreEqual(2, domains.Count); try { hMailServer.Domain secondDomain = newApplication.Domains.get_ItemByName("example.com"); Assert.Fail(); } catch (COMException ex) { Assert.IsTrue(ex.Message.Contains("Invalid index.")); } }
public void TestNormalUserAccessOtherAccount() { hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test"); account.AdminLevel = hMailServer.eAdminLevel.hAdminLevelNormal; account.Save(); hMailServer.Account secondAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test"); secondAccount.AdminLevel = hMailServer.eAdminLevel.hAdminLevelNormal; secondAccount.Save(); hMailServer.Application newApplication = new hMailServer.Application(); newApplication.Authenticate("*****@*****.**", "test"); Assert.AreEqual(1, newApplication.Domains.Count); Assert.AreEqual(1, newApplication.Domains[0].Accounts.Count); hMailServer.Account myAccount = newApplication.Domains[0].Accounts.get_ItemByAddress("*****@*****.**"); try { hMailServer.Account otherAccount = newApplication.Domains[0].Accounts.get_ItemByAddress("*****@*****.**"); Assert.Fail(); } catch (COMException ex) { Assert.IsTrue(ex.Message.Contains("Invalid index.")); } hMailServer.Domains domains = SingletonProvider <Utilities> .Instance.GetApp().Domains; Assert.AreEqual(2, domains[0].Accounts.Count); }
public void TestInsertionOfTooLongString() { Stopwatch watch = new Stopwatch(); hMailServer.Application application = SingletonProvider <Utilities> .Instance.GetApp(); hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test"); StringBuilder sb = new StringBuilder(); for (int i = 0; i < 1000; i++) { sb.Append("abcdefgh"); } account.PersonFirstName = sb.ToString(); try { watch.Start(); account.Save(); } catch (Exception) { } watch.Stop(); Assert.Greater(1500, watch.ElapsedMilliseconds); // an error log file may have been created. if we're using MySQL, // the value may have been silently truncated. Utilities.AssertDeleteFile(Utilities.GetErrorLogFileName()); }
public void TestForwarding() { // Create a test account // Fetch the default domain hMailServer.Account oAccount1 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test"); hMailServer.Account oAccount2 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test"); // Set up account 1 to forward to account2. oAccount1.ForwardEnabled = true; oAccount1.ForwardAddress = "*****@*****.**"; oAccount1.ForwardKeepOriginal = true; oAccount1.Save(); // Send 2 messages to this account. SMTPClientSimulator oSMTP = new SMTPClientSimulator(); for (int i = 0; i < 2; i++) { oSMTP.Send("*****@*****.**", "*****@*****.**", "INBOX", "POP3 test message"); } POP3Simulator.AssertMessageCount(oAccount1.Address, "test", 2); // Tell hMailServer to deliver now, so that the forward takes effect. SingletonProvider <Utilities> .Instance.GetApp().SubmitEMail(); POP3Simulator.AssertMessageCount(oAccount2.Address, "test", 2); }
public void TestAutoReplySubject() { // Create a test account // Fetch the default domain hMailServer.Account oAccount1 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, Utilities.RandomString() + "@test.com", "test"); hMailServer.Account oAccount2 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, Utilities.RandomString() + "@test.com", "test"); oAccount2.VacationMessageIsOn = true; oAccount2.VacationMessage = "I'm on vacation"; oAccount2.VacationSubject = "Auto-Reply: %SUBJECT%"; oAccount2.Save(); // Send 1 message to this account SMTPClientSimulator oSMTP = new SMTPClientSimulator(); oSMTP.Send(oAccount1.Address, oAccount2.Address, "Test message", "This is the body"); // Wait a second to be sure that the message // are delivered. // Check using POP3 that 2 messages exists. POP3Simulator oPOP3 = new POP3Simulator(); POP3Simulator.AssertMessageCount(oAccount1.Address, "test", 1); string s = oPOP3.GetFirstMessageText(oAccount1.Address, "test"); if (s.IndexOf("Subject: Auto-Reply: Test message") < 0) { throw new Exception("ERROR - Auto reply subject not set properly."); } }
public void TestForwardingAndDelete() { // Create a test account // Fetch the default domain hMailServer.Account oAccount1 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test"); hMailServer.Account oAccount2 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test"); // Set up account 1 to forward to account2. oAccount1.ForwardEnabled = true; oAccount1.ForwardAddress = "*****@*****.**"; oAccount1.ForwardKeepOriginal = false; oAccount1.Save(); // Send 2 messages to this account. SMTPClientSimulator oSMTP = new SMTPClientSimulator(); oSMTP.Send("*****@*****.**", "*****@*****.**", "INBOX", "POP3 test message"); Utilities.AssertRecipientsInDeliveryQueue(0); POP3Simulator.AssertMessageCount(oAccount2.Address, "test", 1); string domainDir = Path.Combine(_settings.Directories.DataDirectory, "test.com"); string userDir = Path.Combine(domainDir, "Forward1"); string[] dirs = Directory.GetDirectories(userDir); foreach (string dir in dirs) { string[] files = Directory.GetFiles(dir); Assert.AreEqual(0, files.Length); } }
public void TestAutoReplyCombinedWithForwarding() { // Create a test account // Fetch the default domain hMailServer.Account oAccount1 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, Utilities.RandomString() + "@test.com", "test"); hMailServer.Account oAccount2 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, Utilities.RandomString() + "@test.com", "test"); hMailServer.Account oAccount3 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, Utilities.RandomString() + "@test.com", "test"); oAccount2.VacationMessageIsOn = true; oAccount2.VacationMessage = "I'm on vacation"; oAccount2.VacationSubject = "Out of office!"; oAccount2.ForwardAddress = oAccount3.Address; oAccount2.ForwardEnabled = true; oAccount2.ForwardKeepOriginal = true; oAccount2.Save(); // Send a message... SMTPClientSimulator oSMTP = new SMTPClientSimulator(); oSMTP.Send(oAccount1.Address, oAccount2.Address, "Test message", "This is the body"); SingletonProvider <Utilities> .Instance.GetApp().SubmitEMail(); Utilities.AssertRecipientsInDeliveryQueue(0); // Wait for the auto-reply. POP3Simulator.AssertMessageCount(oAccount1.Address, "test", 1); POP3Simulator.AssertMessageCount(oAccount2.Address, "test", 1); POP3Simulator.AssertMessageCount(oAccount3.Address, "test", 1); }
public void ConfirmSingleReturnPathAfterAccountForward() { // Create a test account // Fetch the default domain hMailServer.Account oAccount1 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test"); hMailServer.Account oAccount2 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test"); oAccount1.ForwardAddress = oAccount2.Address; oAccount1.ForwardEnabled = true; oAccount1.Save(); // Send a message... SMTPClientSimulator oSMTP = new SMTPClientSimulator(); oSMTP.Send("*****@*****.**", oAccount1.Address, "Test message", "This is the body"); Utilities.AssertRecipientsInDeliveryQueue(0); _application.SubmitEMail(); // Wait for the auto-reply. string text = POP3Simulator.AssertGetFirstMessageText(oAccount2.Address, "test"); Assert.IsFalse(text.Contains("Return-Path: [email protected]")); Assert.IsFalse(text.Contains("Return-Path: [email protected]")); Assert.IsTrue(text.Contains("Return-Path: [email protected]")); }
public void TestAutoReplySubjectInBody() { // Create a test account // Fetch the default domain hMailServer.Account oAccount1 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, Utilities.RandomString() + "@test.com", "test"); hMailServer.Account oAccount2 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, Utilities.RandomString() + "@test.com", "test"); oAccount2.VacationMessageIsOn = true; oAccount2.VacationMessage = "Your message regarding -%SUBJECT%- was not received."; oAccount2.VacationSubject = "Auto-Reply: Out of office"; oAccount2.Save(); // Send 1 message to this account SMTPClientSimulator oSMTP = new SMTPClientSimulator(); oSMTP.Send(oAccount1.Address, oAccount2.Address, "Test message", "This is the body"); string s = POP3Simulator.AssertGetFirstMessageText(oAccount1.Address, "test"); if (s.IndexOf("Your message regarding -Test message- was not received.") < 0) { throw new Exception("ERROR - Auto reply subject not set properly."); } }
public void TestDomainLimitAccountMaxSizeTest1() { _domain.MaxAccountSize = 25; _domain.Save(); hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "secret1", 1); account.Save(); }
public void AddAccount(string address, string password) { hMailServer.Account account = DomainUtil.GetDomain(address).Accounts.Add(); account.Address = address; account.Password = password; account.Active = true; account.AdminLevel = hMailServer.eAdminLevel.hAdminLevelNormal; account.MaxSize = 20; account.Save(); }
public void TestSignature() { domain.SignatureEnabled = true; domain.AddSignaturesToLocalMail = true; hMailServer.Account oAccount1 = SingletonProvider <Utilities> .Instance.AddAccount(domain, "*****@*****.**", "test"); oAccount1.SignatureEnabled = true; SMTPClientSimulator oSMTP = new SMTPClientSimulator(); oSMTP.Send(oAccount1.Address, oAccount1.Address, "Test of signature, 1", "Test of signature - Body"); string sMessageData = POP3Simulator.AssertGetFirstMessageText(oAccount1.Address, "test"); if (sMessageData.IndexOf("PlainTextSignature") > 0) { throw new Exception("Found exception which should not be there"); } oAccount1.SignaturePlainText = "PlainTextSignature"; oAccount1.Save(); oSMTP.Send(oAccount1.Address, oAccount1.Address, "Test of signature, 2", "Test of signature - Body"); sMessageData = POP3Simulator.AssertGetFirstMessageText(oAccount1.Address, "test"); if (sMessageData.IndexOf("PlainTextSignature") < 0) { throw new Exception("Did not find expected signature"); } // Turn off signature again oAccount1.SignatureEnabled = false; oAccount1.Save(); oSMTP.Send(oAccount1.Address, oAccount1.Address, "Test of signature, 2", "Test of signature - Body"); sMessageData = POP3Simulator.AssertGetFirstMessageText(oAccount1.Address, "test"); if (sMessageData.IndexOf("PlainTextSignature") > 0) { throw new Exception("Found signature even though there shouldn't be any"); } }
public hMailServer.Account AddAccount(hMailServer.Accounts accounts, string sAddress, string sPassword) { hMailServer.Account oAccount = accounts.Add(); oAccount.Address = sAddress; oAccount.Password = sPassword; oAccount.Active = true; oAccount.Save(); return(oAccount); }
public void TestForwardingCombinedWithAccountRule() { // Create a test account // Fetch the default domain hMailServer.Account oAccount1 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, Utilities.RandomString() + "@test.com", "test"); hMailServer.Account oAccount2 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, Utilities.RandomString() + "@test.com", "test"); hMailServer.Account oAccount3 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, Utilities.RandomString() + "@test.com", "test"); oAccount2.ForwardAddress = oAccount3.Address; oAccount2.ForwardEnabled = true; oAccount2.ForwardKeepOriginal = true; oAccount2.Save(); SMTPClientSimulator oSMTP = new SMTPClientSimulator(); Assert.IsTrue(oSMTP.Send(oAccount1.Address, oAccount2.Address, "Test message", "This is the body")); // Make sure that that a forward is made if no rule is set up. POP3Simulator.AssertMessageCount(oAccount2.Address, "test", 1); _application.SubmitEMail(); POP3Simulator.AssertMessageCount(oAccount3.Address, "test", 1); // Start over again. oAccount2.DeleteMessages(); oAccount3.DeleteMessages(); // Set up a rule to trash the message. hMailServer.Rule oRule = oAccount2.Rules.Add(); oRule.Name = "Criteria test"; oRule.Active = true; hMailServer.RuleCriteria oRuleCriteria = oRule.Criterias.Add(); oRuleCriteria.UsePredefined = true; oRuleCriteria.PredefinedField = hMailServer.eRulePredefinedField.eFTMessageSize; oRuleCriteria.MatchType = hMailServer.eRuleMatchType.eMTGreaterThan; oRuleCriteria.MatchValue = "0"; oRuleCriteria.Save(); // Add action hMailServer.RuleAction oRuleAction = oRule.Actions.Add(); oRuleAction.Type = hMailServer.eRuleActionType.eRADeleteEmail; oRuleAction.Save(); // Save the rule in the database oRule.Save(); // Make sure that that a forward is made if no rule is set up. Assert.IsTrue(oSMTP.Send(oAccount1.Address, oAccount2.Address, "Test message", "This is the body")); POP3Simulator.AssertMessageCount(oAccount2.Address, "test", 0); _application.SubmitEMail(); POP3Simulator.AssertMessageCount(oAccount3.Address, "test", 0); }
public void TestDomainAdminAccessBackupManager() { hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test"); account.AdminLevel = hMailServer.eAdminLevel.hAdminLevelDomainAdmin; account.Save(); hMailServer.Application newApplication = new hMailServer.Application(); newApplication.Authenticate("*****@*****.**", "test"); hMailServer.BackupManager backupManager = newApplication.BackupManager; }
public void TestNormalUserAccessSettings() { hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test"); account.AdminLevel = hMailServer.eAdminLevel.hAdminLevelNormal; account.Save(); hMailServer.Application newApplication = new hMailServer.Application(); newApplication.Authenticate("*****@*****.**", "test"); hMailServer.Settings settings = newApplication.Settings; }
public hMailServer.Account AddAccount(hMailServer.Domain oDomain, string sAddress, string sPassword, int maxSize) { hMailServer.Account oAccount = oDomain.Accounts.Add(); oAccount.Address = sAddress; oAccount.Password = sPassword; oAccount.Active = true; oAccount.MaxSize = maxSize; oAccount.Save(); return(oAccount); }
public void TestDomainAdminAccessDatabase() { hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test"); account.AdminLevel = hMailServer.eAdminLevel.hAdminLevelDomainAdmin; account.Save(); hMailServer.Application newApplication = new hMailServer.Application(); newApplication.Authenticate("*****@*****.**", "test"); hMailServer.Database database = newApplication.Database; database.ExecuteSQL("select"); }
internal void OnAddADAccount(object sender, EventArgs e) { formActiveDirectoryAccounts accountsDlg = new formActiveDirectoryAccounts(); if (accountsDlg.ShowDialog() == DialogResult.OK) { hMailServer.Domain domain = APICreator.GetDomain(_domainID); hMailServer.Accounts accounts = domain.Accounts; Instances.MainForm.Cursor = Cursors.WaitCursor; string domainName = accountsDlg.DomainName; List <string> accountNames = accountsDlg.AccountNames; foreach (string accountName in accountNames) { try { hMailServer.Account account = accounts.Add(); account.IsAD = true; account.ADDomain = domainName; account.ADUsername = accountName; account.Active = true; string address = accountName; address = address.Replace(" ", "."); address = address + "@" + domain.Name; account.Address = address; account.Save(); Marshal.ReleaseComObject(account); } catch (Exception ex) { MessageBox.Show(ex.Message, EnumStrings.hMailServerAdministrator); } } Marshal.ReleaseComObject(domain); Marshal.ReleaseComObject(accounts); Instances.MainForm.Cursor = Cursors.Default; } IMainForm mainForm = Instances.MainForm; mainForm.RefreshCurrentNode(null); mainForm.ShowItem(mainForm.GetCurrentNode()); }
public void ServerAdminShouldBeAbleToAddDomain() { hMailServer.Domain domain = SingletonProvider <Utilities> .Instance.AddTestDomain(); // Create an account with normal privileges. hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(domain, "*****@*****.**", "test"); account.AdminLevel = hMailServer.eAdminLevel.hAdminLevelServerAdmin; account.Save(); hMailServer.Application newApp = new hMailServer.Application(); hMailServer.Account authenticated = newApp.Authenticate(account.Address, "test"); Assert.IsNotNull(authenticated); // This should throw an exception. hMailServer.Domain newDomain = newApp.Domains.Add(); }
public void TestRenameDomainWithAccountForward() { hMailServer.Account oAccount1 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test"); oAccount1.ForwardAddress = "*****@*****.**"; oAccount1.Save(); hMailServer.Account oAccount2 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test"); oAccount2.ForwardAddress = "*****@*****.**"; oAccount2.Save(); _domain.Name = "example.com"; _domain.Save(); Assert.AreEqual("*****@*****.**", _domain.Accounts[0].ForwardAddress); Assert.AreEqual("*****@*****.**", _domain.Accounts[1].ForwardAddress); }
public void TestAccountSignatureMacro() { domain.SignatureEnabled = true; domain.AddSignaturesToLocalMail = true; hMailServer.Account oAccount1 = SingletonProvider <Utilities> .Instance.AddAccount(domain, "*****@*****.**", "test"); oAccount1.PersonFirstName = "Martin"; oAccount1.PersonLastName = "Knafve"; oAccount1.SignatureEnabled = true; oAccount1.SignaturePlainText = "Regards %User.FirstName% %User.Lastname%"; oAccount1.Save(); SMTPClientSimulator.StaticSend(oAccount1.Address, oAccount1.Address, "Test of signature, 2", "Test of signature - Body"); string sMessageData = POP3Simulator.AssertGetFirstMessageText(oAccount1.Address, "test"); Assert.IsTrue(sMessageData.Contains("Regards Martin Knafve")); }
public void UserShouldNotBeAbleToSaveDomain() { hMailServer.Domain domain = SingletonProvider <Utilities> .Instance.AddTestDomain(); // Create an account with normal privileges. hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(domain, "*****@*****.**", "test"); account.AdminLevel = hMailServer.eAdminLevel.hAdminLevelNormal; account.Save(); hMailServer.Application newApp = new hMailServer.Application(); hMailServer.Account authenticated = newApp.Authenticate(account.Address, "test"); Assert.IsNotNull(authenticated); Assert.AreEqual(1, newApp.Domains.Count); // Retrieve our domain. hMailServer.Domain newDomain = newApp.Domains[0]; newDomain.Save(); }
private void SetupAccountObject(hMailServer.Domain domain) { hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(domain, "*****@*****.**", "test"); // Make sure the inbox contains two messages which should be backed up. Assert.IsTrue(SMTPClientSimulator.StaticSend(account.Address, account.Address, "Message 1 Subject", "Message 1 Body")); POP3Simulator.AssertMessageCount(account.Address, "test", 1); Assert.IsTrue(SMTPClientSimulator.StaticSend(account.Address, account.Address, "Message 2 Subject", "Message 2 Body")); POP3Simulator.AssertMessageCount(account.Address, "test", 2); Assert.IsTrue(SMTPClientSimulator.StaticSend(account.Address, account.Address, "Message 3 Subject", "Message 3 Body")); POP3Simulator.AssertMessageCount(account.Address, "test", 3); IMAPSimulator sim = new IMAPSimulator(); Assert.IsTrue(sim.ConnectAndLogon(account.Address, "test")); Assert.IsTrue(sim.SelectFolder("Inbox")); Assert.IsTrue(sim.SetDeletedFlag(2)); Assert.IsTrue(sim.Expunge()); sim.Disconnect(); _folderCreationTime = account.IMAPFolders.get_ItemByName("INBOX").CreationTime; account.Active = true; account.ADDomain = "AD"; account.AdminLevel = hMailServer.eAdminLevel.hAdminLevelDomainAdmin; account.ADUsername = "******"; account.ForwardAddress = "FA"; account.ForwardEnabled = false; account.ForwardKeepOriginal = true; account.IsAD = false; account.MaxSize = 1250; account.PersonFirstName = "First"; account.PersonLastName = "Last"; account.SignatureEnabled = true; account.SignatureHTML = "HTML"; account.SignaturePlainText = "PLAIN"; account.VacationMessage = "VAC"; account.VacationMessageExpires = true; account.VacationMessageExpiresDate = "2020-01-01"; account.VacationMessageIsOn = true; account.VacationSubject = "SUBJ"; account.Password = "******"; account.Save(); // Set up fetch account hMailServer.FetchAccount fa = account.FetchAccounts.Add(); fa.DaysToKeepMessages = 5; fa.Enabled = true; fa.MinutesBetweenFetch = 10; fa.Name = "test"; fa.Port = 1110; fa.ProcessMIMEDate = true; fa.ProcessMIMERecipients = true; fa.ServerAddress = "127.0.0.1"; fa.Username = "******"; fa.UseSSL = false; fa.UseAntiSpam = true; fa.UseAntiVirus = true; fa.Save(); DownloadFromExternalAccount(account, fa); hMailServer.Rule rule = account.Rules.Add(); rule.Name = "MyRule"; hMailServer.RuleCriteria criteria = rule.Criterias.Add(); criteria.MatchType = hMailServer.eRuleMatchType.eMTGreaterThan; criteria.PredefinedField = hMailServer.eRulePredefinedField.eFTMessageSize; criteria.MatchValue = "0"; criteria.Save(); hMailServer.RuleAction action = rule.Actions.Add(); action.Type = hMailServer.eRuleActionType.eRAForwardEmail; action.To = "*****@*****.**"; action.Body = "Test"; action.Filename = "File"; action.FromAddress = "T"; action.FromName = "N"; action.HeaderName = "H"; action.IMAPFolder = "Folder"; action.ScriptFunction = "Script"; action.Subject = "Subj"; action.Value = "Value"; action.Save(); rule.Save(); }
public void ChangePassword(string address, string password) { hMailServer.Account account = DomainUtil.GetDomain(address).Accounts.get_ItemByAddress(address); account.Password = password; account.Save(); }
public bool SaveData() { if (!ValidateForm()) { return(false); } bool newAccount = false; if (_representedAccount == null) { hMailServer.Domain domain = APICreator.GetDomain(_domainID); hMailServer.Accounts accounts = domain.Accounts; _representedAccount = accounts.Add(); Marshal.ReleaseComObject(accounts); Marshal.ReleaseComObject(domain); } if (_representedAccount.ID == 0) { newAccount = true; } _representedAccount.Address = textAddress.Text; _representedAccount.MaxSize = textMaxSize.Number; _representedAccount.Active = checkEnabled.Checked; _representedAccount.VacationMessageIsOn = checkVacationMessageEnable.Checked; _representedAccount.VacationSubject = textVacationMessageSubject.Text; _representedAccount.VacationMessage = textVacationMessageText.Text; _representedAccount.VacationMessageExpires = checkVacationMessageExpires.Checked; _representedAccount.VacationMessageExpiresDate = dateVacationMessageExpiresDate.FormattedValue; _representedAccount.ForwardEnabled = checkForwardEnabled.Checked; _representedAccount.ForwardAddress = textForwardAddress.Text; _representedAccount.ForwardKeepOriginal = checkForwardKeepOriginal.Checked; _representedAccount.SignatureEnabled = checkSignatureEnabled.Checked; _representedAccount.SignaturePlainText = textSignaturePlainText.Text; _representedAccount.SignatureHTML = textSignatureHTML.Text; _representedAccount.IsAD = checkAccountIsAD.Checked; _representedAccount.ADDomain = textADDomain.Text; _representedAccount.ADUsername = textADUsername.Text; _representedAccount.PersonFirstName = textFirstName.Text; _representedAccount.PersonLastName = textLastName.Text; _representedAccount.AdminLevel = (hMailServer.eAdminLevel)comboAdministrationLevel.SelectedValue; if (textPassword.Dirty) { _representedAccount.Password = textPassword.Password; } _representedAccount.Save(); // Refresh the node in the tree if the name has changed. IMainForm mainForm = Instances.MainForm; mainForm.RefreshCurrentNode(_representedAccount.Address); // Set the object to clean. DirtyChecker.SetClean(this); if (newAccount) { SearchNodeText crit = new SearchNodeText(_representedAccount.Address); mainForm.SelectNode(crit); } else { EnableDisable(); } return(true); }
public void Save() { _object.Save(); }
public void TestDomainSignature() { POP3Simulator oPOP3 = new POP3Simulator(); domain.SignatureEnabled = true; domain.AddSignaturesToLocalMail = true; hMailServer.Account oAccount1 = SingletonProvider <Utilities> .Instance.AddAccount(domain, "*****@*****.**", "test"); oAccount1.SignatureEnabled = true; oAccount1.SignaturePlainText = "PlainTextSignature"; oAccount1.Save(); SMTPClientSimulator oSMTP = new SMTPClientSimulator(); oSMTP.Send(oAccount1.Address, oAccount1.Address, "Test of signature, 1", "Test of signature - Body"); string sMessageContents = POP3Simulator.AssertGetFirstMessageText(oAccount1.Address, "test"); if (sMessageContents.IndexOf("PlainTextSignature") <= 0) { throw new Exception("Did not find signature"); } domain.SignatureEnabled = true; domain.SignaturePlainText = "DomainSignature"; domain.SignatureMethod = hMailServer.eDomainSignatureMethod.eSMAppendToAccountSignature; domain.Save(); oSMTP.Send(oAccount1.Address, oAccount1.Address, "Test of signature, 1", "Test of signature - Body"); sMessageContents = POP3Simulator.AssertGetFirstMessageText(oAccount1.Address, "test"); if (sMessageContents.IndexOf("PlainTextSignature") <= 0 || sMessageContents.IndexOf("DomainSignature") <= 0) { throw new Exception("Did not find signature"); } domain.SignatureEnabled = true; domain.SignaturePlainText = "DomainSignature"; domain.SignatureMethod = hMailServer.eDomainSignatureMethod.eSMOverwriteAccountSignature; domain.Save(); oSMTP.Send(oAccount1.Address, oAccount1.Address, "Test of signature, 1", "Test of signature - Body"); sMessageContents = POP3Simulator.AssertGetFirstMessageText(oAccount1.Address, "test"); if (sMessageContents.IndexOf("PlainTextSignature") >= 0 || sMessageContents.IndexOf("DomainSignature") <= 0) { throw new Exception("Did not find signature"); } domain.SignatureEnabled = true; domain.SignaturePlainText = "DomainSignature"; domain.SignatureMethod = hMailServer.eDomainSignatureMethod.eSMSetIfNotSpecifiedInAccount; domain.Save(); oSMTP.Send(oAccount1.Address, oAccount1.Address, "Test of signature, 1", "Test of signature - Body"); sMessageContents = POP3Simulator.AssertGetFirstMessageText(oAccount1.Address, "test"); if (sMessageContents.IndexOf("DomainSignature") >= 0) { throw new Exception("Found incorrect signature."); } domain.SignatureEnabled = true; domain.SignaturePlainText = "DomainSignature"; domain.SignatureMethod = hMailServer.eDomainSignatureMethod.eSMSetIfNotSpecifiedInAccount; domain.Save(); oAccount1.SignaturePlainText = ""; oAccount1.Save(); oSMTP.Send(oAccount1.Address, oAccount1.Address, "Test of signature, 1", "Test of signature - Body"); sMessageContents = POP3Simulator.AssertGetFirstMessageText(oAccount1.Address, "test"); if (sMessageContents.IndexOf("DomainSignature") <= 0) { throw new Exception("Found incorrect signature."); } domain.AddSignaturesToLocalMail = false; domain.Save(); oAccount1.SignaturePlainText = "PlainTextSignature"; oAccount1.Save(); oSMTP.Send(oAccount1.Address, oAccount1.Address, "Test of signature, 1", "Test of signature - Body"); sMessageContents = POP3Simulator.AssertGetFirstMessageText(oAccount1.Address, "test"); if (sMessageContents.IndexOf("PlainTextSignature") > 0) { throw new Exception("Found incorrect signature."); } domain.AddSignaturesToLocalMail = true; domain.Save(); oSMTP.Send(oAccount1.Address, oAccount1.Address, "Test of signature, 1", "Test of signature - Body"); sMessageContents = POP3Simulator.AssertGetFirstMessageText(oAccount1.Address, "test"); if (sMessageContents.IndexOf("PlainTextSignature") <= 0) { throw new Exception("Found incorrect signature."); } }