protected MailboxModel(int id, int tenant, IMailAddress address, IMailAccount account, ICollection<IMailAddress> aliases, MailServerBase server) : base(new MailAccountBase(account), new MailAddressBase(address), (aliases.Select(a => new MailAddressBase(a)).ToList())) { if (id < 0) throw new ArgumentException("Invalid domain id", "id"); if (tenant < 0) throw new ArgumentException("Invalid tenant id", "tenant"); if (account == null) throw new ArgumentException("Invalid account", "account"); if (address == null) throw new ArgumentException("Invalid address", "address"); if (aliases == null) throw new ArgumentException("Invalid aliases", "aliases"); if (server == null) throw new ArgumentException("Invalid server", "server"); Id = id; Tenant = tenant; Account = account; Address = address; Aliases = aliases; Server = server; }
public void SetUp() { server = TestContext.CreateServer(); peter_domain = server.CreateWebDomain(_peterDomainName, IS_VERIFIED, TestContext.ServerFactory); peter_address = TestContext.CreateRandomMailAddress(peter_domain); peter_account = TestContext.GetMailAccount(peter_address.LocalPart, _peterDomainName); }
private void AddAccountClick(object sender, RoutedEventArgs e) { if (SourceComboBox.SelectedItem != null) { IMailAccount account = null; if ("Imap".Equals(((ComboBoxItem)(SourceComboBox.SelectedItem)).Content)) { account = new ImapAccount(); } else if ("Mbox".Equals(((ComboBoxItem)(SourceComboBox.SelectedItem)).Content)) { account = new MboxAccount(); } else if ("Exchange".Equals(((ComboBoxItem)(SourceComboBox.SelectedItem)).Content)) { account = new ExchangeAccount(); } else { Logger.Warn("Unsupported Account '" + ((ComboBoxItem)(SourceComboBox.SelectedItem)).Content + "'"); } if (account != null) { account.AddedMailbox += AddMailboxEvent; account.RemovedMailbox += RemoveMailboxEvent; MailSources.Add(account); } } }
public MboxAccountControl(MboxAccount account) { InitializeComponent(); Account = account; account.Mailboxes.CollectionChanged += MailboxesOnCollectionChanged; _dataContext = new MBoxAccountDataContext(account, RemoveMailboxFunction); DataContext = _dataContext; }
public MailKitSmtpClient(SmtpClient client, IMailAccount account) { Guard.NotNull(client, nameof(client)); Guard.NotNull(account, nameof(account)); _client = client; Account = account; }
public void Init() { server = TestContext.CreateServer(); peter_domain = server.CreateWebDomain(_peterDomainName, IS_VERIFIED, TestContext.ServerFactory); peter_address = TestContext.CreateRandomMailAddress(peter_domain); peter_second_address = TestContext.CreateRandomMailAddress(peter_domain); peter_alias = TestContext.CreateRandomMailAddress(peter_domain); peter_account = TestContext.GetMailAccount(peter_address.LocalPart, _peterDomainName); peter_second_account = TestContext.GetMailAccount(peter_second_address.LocalPart, _peterDomainName); peter_mailbox = server.CreateMailbox(peter_address.LocalPart, PETER_PASSWORD, peter_domain, peter_account, TestContext.ServerFactory); peter_second_mailbox = server.CreateMailbox(peter_second_address.LocalPart, PETER_PASSWORD, peter_domain, peter_second_account, TestContext.ServerFactory); }
public void Init() { server = TestContext.CreateServer(); peter_domain = server.CreateWebDomain(_peterDomainName, _isVerified, TestContext.ServerFactory); peter_address = TestContext.CreateRandomMailAddress(peter_domain); peter_second_address = TestContext.CreateRandomMailAddress(peter_domain); peter_alias = TestContext.CreateRandomMailAddress(peter_domain); peter_account = TestContext.GetMailAccount(peter_address.LocalPart, _peterDomainName); peter_second_account = TestContext.GetMailAccount(peter_second_address.LocalPart, _peterDomainName); peter_mailbox = server.CreateMailbox(peter_address.LocalPart, PeterPassword, peter_domain, peter_account, TestContext.ServerFactory); peter_second_mailbox = server.CreateMailbox(peter_second_address.LocalPart, PeterPassword, peter_domain, peter_second_account, TestContext.ServerFactory); }
public virtual async Task <ISmtpClient> ConnectAsync(IMailAccount account, int timeout = 1000) { Guard.NotNull(account, nameof(account)); var mClient = new SmtpClient { ServerCertificateValidationCallback = ValidateServerCertificate, Timeout = timeout }; var client = new MailKitSmtpClient(mClient, account); await client.ConnectAsync(); return(client); }
private void RemoveMailSource(IMailAccount item) { if (item != null) { if (MailSources.Contains(item)) { int mbCount = item.Mailboxes.Count; if (mbCount > 0) { for (int i = mbCount - 1; i >= 0; i--) { RemoveMailboxById(item.Mailboxes[i].Id); } } MailSources.Remove(item); Logger.Debug("Removed mailbox " + item); } } }
protected MailboxModel(int id, int tenant, IMailAddress address, string name, IMailAccount account, ICollection <IMailAddress> aliases, MailServerBase server) : base(new MailAccountBase(account), new MailAddressBase(address), name, (aliases.Select(a => new MailAddressBase(a)).ToList())) { if (id < 0) { throw new ArgumentException("Invalid domain id", "id"); } if (tenant < 0) { throw new ArgumentException("Invalid tenant id", "tenant"); } if (account == null) { throw new ArgumentException("Invalid account", "account"); } if (address == null) { throw new ArgumentException("Invalid address", "address"); } if (aliases == null) { throw new ArgumentException("Invalid aliases", "aliases"); } if (server == null) { throw new ArgumentException("Invalid server", "server"); } Id = id; Tenant = tenant; Account = account; Address = address; Aliases = aliases; Server = server; }
public abstract IMailbox CreateMailbox(int id, int tenant, IMailAddress address, IMailAccount account, List <IMailAddress> aliases, MailServerBase server);
public override IMailbox CreateMailbox(string name, string localpart, string password, IWebDomain domain, IMailAccount account, IMailServerFactory factory) { if (string.IsNullOrEmpty(localpart)) { throw new ArgumentNullException("localpart"); } if (domain == null) { throw new ArgumentNullException("domain"); } if (account == null) { throw new ArgumentNullException("account"); } if (localpart.Length + domain.Name.Length > 318) // 318 because of @ sign { throw new ArgumentException("Address of mailbox exceed limitation of 319 characters.", "localpart"); } var mailboxBase = new MailboxBase(new MailAccountBase(account.Login), new MailAddressBase(localpart, new WebDomainBase(domain)), name, new List <MailAddressBase>()) { Address = { DateCreated = DateTime.UtcNow } }; MailboxWithAddressDto mailboxWithAddressDto; using (var dbContextWithTran = TeamlabMailboxDal.CreateMailDbContext(true)) { mailboxWithAddressDto = TeamlabMailboxDal.CreateMailbox(account.TeamlabAccount, mailboxBase.Name, mailboxBase.Address.ToString(), password, mailboxBase.Address.LocalPart, mailboxBase.Address.DateCreated, domain.Id, domain.Name, domain.IsVerified, dbContextWithTran.DbManager); _CreateMailbox(account.Login, password, localpart, domain.Name, name); dbContextWithTran.CommitTransaction(); } var mailboxAddress = factory.CreateMailAddress(mailboxWithAddressDto.mailbox_address.id, mailboxWithAddressDto.mailbox_address.tenant, mailboxWithAddressDto.mailbox_address.name, domain); var mailbox = factory.CreateMailbox(mailboxWithAddressDto.mailbox.id, mailboxWithAddressDto.mailbox.tenant, mailboxAddress, mailboxWithAddressDto.mailbox.name, account, new List <IMailAddress>(), this); return(mailbox); }
public override IMailbox CreateMailbox(string localpart, string password, IWebDomain domain, IMailAccount account, IMailServerFactory factory) { if (string.IsNullOrEmpty(localpart)) throw new ArgumentNullException("localpart"); if(domain == null) throw new ArgumentNullException("domain"); if (account == null) throw new ArgumentNullException("account"); if (localpart.Length + domain.Name.Length > 318) // 318 because of @ sign throw new ArgumentException("Address of mailbox exceed limitation of 319 characters.", "localpart"); var mailboxBase = new MailboxBase(new MailAccountBase(account.Login), new MailAddressBase(localpart, new WebDomainBase(domain)), new List<MailAddressBase>()) { DateCreated = DateTime.UtcNow }; MailboxWithAddressDto mailboxWithAddressDto; using (var dbContextWithTran = TeamlabMailboxDal.CreateMailDbContext(true)) { mailboxWithAddressDto = TeamlabMailboxDal.CreateMailbox(account.TeamlabAccount, mailboxBase.Address.ToString(), password, mailboxBase.Address.LocalPart, mailboxBase.Address.DateCreated, domain.Id, domain.Name, domain.IsVerified, dbContextWithTran.DbManager); _CreateMailbox(account.Login, password, localpart, domain.Name); dbContextWithTran.CommitTransaction(); } var mailboxAddress = factory.CreateMailAddress(mailboxWithAddressDto.mailbox_address.id, mailboxWithAddressDto.mailbox_address.tenant, mailboxWithAddressDto.mailbox_address.name, domain) ; var mailbox = factory.CreateMailbox(mailboxWithAddressDto.mailbox.id, mailboxWithAddressDto.mailbox.tenant, mailboxAddress, account, new List<IMailAddress>(), this); return mailbox; }
public MailAccountBase(IMailAccount mailAccount) :this(mailAccount.Login) { }
public abstract IMailbox CreateMailbox(string localpart, string password, IWebDomain domain, IMailAccount account, IMailServerFactory factory);
public PostfixMailbox(int id, int tenant, IMailAddress address, IMailAccount account, List <IMailAddress> aliases, MailServerBase server) : base(id, tenant, address, account, aliases, server) { }
public PostfixMailbox(int id, int tenant, IMailAddress address, IMailAccount account, List<IMailAddress> aliases, MailServerBase server) : base(id, tenant, address, account, aliases, server) { }
public MockMailbox(int id, int tenant, IMailAddress address, IMailAccount account, List<IMailAddress> aliases, MailServerBase server) : base(id, tenant, address, account, aliases, server) { _serverData = MockServerData.GetInstance(); }
public override IMailbox CreateMailbox(int id, int tenant, IMailAddress address, string name, IMailAccount account, List <IMailAddress> aliases, MailServerBase server) { return(new MockMailbox(id, tenant, address, name, account, aliases, server)); }
public override IMailbox CreateMailbox(int id, int tenant, IMailAddress address, IMailAccount account, List<IMailAddress> aliases, MailServerBase server) { return new PostfixMailbox(id, tenant, address, account, aliases, server); }
public MockMailbox(int id, int tenant, IMailAddress address, IMailAccount account, List <IMailAddress> aliases, MailServerBase server) : base(id, tenant, address, account, aliases, server) { _serverData = MockServerData.GetInstance(); }
public MailAccountBase(IMailAccount mail_account) : this(mail_account.Login) { }
public abstract IMailbox CreateMailbox(int id, int tenant, IMailAddress address, IMailAccount account, List<IMailAddress> aliases, MailServerBase server);
public override IMailbox CreateMailbox(int id, int tenant, IMailAddress address, IMailAccount account, List <IMailAddress> aliases, MailServerBase server) { return(new PostfixMailbox(id, tenant, address, account, aliases, server)); }