コード例 #1
1
        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;
        }
コード例 #2
0
 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);
 }
コード例 #3
0
 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);
         }
     }
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 public MboxAccountControl(MboxAccount account)
 {
     InitializeComponent();
     Account = account;
     account.Mailboxes.CollectionChanged += MailboxesOnCollectionChanged;
     _dataContext = new MBoxAccountDataContext(account, RemoveMailboxFunction);
     DataContext  = _dataContext;
 }
コード例 #6
0
        public MailKitSmtpClient(SmtpClient client, IMailAccount account)
        {
            Guard.NotNull(client, nameof(client));
            Guard.NotNull(account, nameof(account));

            _client = client;
            Account = account;
        }
コード例 #7
0
 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);
 }
コード例 #8
0
 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);
 }
コード例 #9
0
 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);
 }
コード例 #10
0
        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);
        }
コード例 #11
0
 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);
         }
     }
 }
コード例 #12
0
        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;
        }
コード例 #13
0
 public abstract IMailbox CreateMailbox(int id, int tenant, IMailAddress address, IMailAccount account,
                                        List <IMailAddress> aliases, MailServerBase server);
コード例 #14
0
        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);
        }
コード例 #15
0
ファイル: ServerModel.cs プロジェクト: vipwan/CommunityServer
        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;

        }
コード例 #16
0
 public MailAccountBase(IMailAccount mailAccount)
     :this(mailAccount.Login)
 {
 }
コード例 #17
0
 public abstract IMailbox CreateMailbox(string localpart, string password, IWebDomain domain, IMailAccount account, IMailServerFactory factory);
コード例 #18
0
 public PostfixMailbox(int id, int tenant, IMailAddress address, IMailAccount account, List <IMailAddress> aliases, MailServerBase server)
     : base(id, tenant, address, account, aliases, server)
 {
 }
コード例 #19
0
 public PostfixMailbox(int id, int tenant, IMailAddress address, IMailAccount account, List<IMailAddress> aliases, MailServerBase server) 
     : base(id, tenant, address, account, aliases, server)
 {
 }
コード例 #20
0
ファイル: MockMailbox.cs プロジェクト: vipwan/CommunityServer
 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();
 }
コード例 #21
0
 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));
 }
コード例 #22
0
 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);
 }
コード例 #23
0
 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();
 }
コード例 #24
0
 public MailAccountBase(IMailAccount mail_account)
     : this(mail_account.Login)
 {
 }
コード例 #25
0
 public abstract IMailbox CreateMailbox(int id, int tenant, IMailAddress address, IMailAccount account,
                     List<IMailAddress> aliases, MailServerBase server);
コード例 #26
0
 public abstract IMailbox CreateMailbox(string localpart, string password, IWebDomain domain, IMailAccount account, IMailServerFactory factory);
コード例 #27
0
 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));
 }