コード例 #1
0
ファイル: SmarterMail2.cs プロジェクト: jordan49/websitepanel
        public virtual void CreateGroup(MailGroup group)
        {
            try
            {
                svcAliasAdmin svcGroups = new svcAliasAdmin();
                PrepareProxy(svcGroups);

                GenericResult1 result = svcGroups.AddAlias(AdminUsername, AdminPassword,
                    GetDomainName(group.Name), group.Name, group.Members);

                if (!result.Result)
                    throw new Exception(result.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("Could not create mail domain group", ex);
            }
        }
コード例 #2
0
ファイル: SmarterMail2.cs プロジェクト: jordan49/websitepanel
        public virtual void DeleteGroup(string groupName)
        {
            try
            {
                svcAliasAdmin svcGroups = new svcAliasAdmin();
                PrepareProxy(svcGroups);

                GenericResult1 result = svcGroups.DeleteAlias(AdminUsername, AdminPassword,
                    GetDomainName(groupName), groupName);

                if (!result.Result)
                    throw new Exception(result.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("Could not delete mail domain group", ex);
            }
        }
コード例 #3
0
ファイル: SmarterMail2.cs プロジェクト: jordan49/websitepanel
        public virtual MailGroup[] GetGroups(string domainName)
        {
            try
            {
                svcAliasAdmin svcGroups = new svcAliasAdmin();
                PrepareProxy(svcGroups);

                AliasInfoListResult result = svcGroups.GetAliases(AdminUsername, AdminPassword, domainName);

                if (!result.Result)
                    throw new Exception(result.Message);

                MailGroup[] groups = new MailGroup[result.AliasInfos.Length];
                for (int i = 0; i < groups.Length; i++)
                {
                    groups[i] = new MailGroup();
                    groups[i].Name = result.AliasInfos[i].Name + "@" + domainName;
                    groups[i].Members = result.AliasInfos[i].Addresses;
                    groups[i].Enabled = true; // by default
                }

                return groups;
            }
            catch (Exception ex)
            {
                throw new Exception("Could not get the list of mail domain groups", ex);
            }
        }
コード例 #4
0
ファイル: SmarterMail2.cs プロジェクト: jordan49/websitepanel
        public virtual MailGroup GetGroup(string groupName)
        {
            try
            {
                svcAliasAdmin svcGroups = new svcAliasAdmin();
                PrepareProxy(svcGroups);

                AliasInfoResult result = svcGroups.GetAlias(AdminUsername, AdminPassword,
                    GetDomainName(groupName), groupName);

                if (!result.Result)
                    throw new Exception(result.Message);

                MailGroup group = new MailGroup();
                group.Name = groupName;
                group.Members = result.AliasInfo.Addresses;
                group.Enabled = true; // by default
                return group;
            }
            catch (Exception ex)
            {
                throw new Exception("Could not get mail domain group", ex);
            }
        }
コード例 #5
0
ファイル: SmarterMail2.cs プロジェクト: jordan49/websitepanel
        public void DeleteMailAlias(string mailAliasName)
        {
            try
            {
                svcAliasAdmin aliases = new svcAliasAdmin();
                PrepareProxy(aliases);

                GenericResult1 result = aliases.DeleteAlias(AdminUsername, AdminPassword, GetDomainName(mailAliasName),
                    mailAliasName);

                if (!result.Result)
                    throw new Exception(result.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("Could not delete mailAlias", ex);
            }
        }
コード例 #6
0
ファイル: SmarterMail2.cs プロジェクト: jordan49/websitepanel
        public virtual bool GroupExists(string groupName)
        {
            try
            {
                svcAliasAdmin svcGroups = new svcAliasAdmin();
                PrepareProxy(svcGroups);

                AliasInfoResult result = svcGroups.GetAlias(AdminUsername, AdminPassword,
                    GetDomainName(groupName), groupName);

                return (result.Result
                    && result.AliasInfo.Name != "Empty");
            }
            catch (Exception ex)
            {
                throw new Exception("Could not check whether mail domain group exists", ex);
            }
        }
コード例 #7
0
ファイル: SmarterMail2.cs プロジェクト: jordan49/websitepanel
        public void CreateMailAlias(MailAlias mailAlias)
        {
            try
            {
                svcAliasAdmin aliases = new svcAliasAdmin();
                PrepareProxy(aliases);

                GenericResult1 result = aliases.AddAlias(AdminUsername, AdminPassword,
                                                        GetDomainName(mailAlias.Name), mailAlias.Name,
                                                        new string[] { mailAlias.ForwardTo });


                if (!result.Result)
                    throw new Exception(result.Message);
            }

            catch (Exception ex)
            {
                if (MailAliasExists(mailAlias.Name))
                {
                    DeleteMailAlias(mailAlias.Name);
                }
                Log.WriteError(ex);
                throw new Exception("Could not create mail alias", ex);

            }

        }
コード例 #8
0
ファイル: SmarterMail2.cs プロジェクト: jordan49/websitepanel
        public void UpdateMailAlias(MailAlias mailAlias)
        {
            try
            {
                svcAliasAdmin aliases = new svcAliasAdmin();
                PrepareProxy(aliases);

                GenericResult1 result = aliases.UpdateAlias(AdminUsername, AdminPassword, GetDomainName(mailAlias.Name),
                                                             mailAlias.Name,
                                                             new string[] { mailAlias.ForwardTo });

                if (!result.Result)
                    throw new Exception(result.Message);

            }
            catch (Exception ex)
            {
                throw new Exception("Could not update mailAlias", ex);
            }

        }
コード例 #9
0
ファイル: SmarterMail2.cs プロジェクト: jordan49/websitepanel
        public MailAlias GetMailAlias(string mailAliasName)
        {
            svcAliasAdmin aliases = new svcAliasAdmin();
            PrepareProxy(aliases);


            MailAlias alias = new MailAlias();
            MailAlias newAlias = new MailAlias();

            //convert old alliases created as mailboxes
            if (!MailAliasExists(mailAliasName))
            {
                MailAccount account = GetAccount(mailAliasName);
                newAlias.Name = account.Name;
                newAlias.ForwardTo = account.ForwardingAddresses[0];
                DeleteAccount(mailAliasName);
                CreateMailAlias(newAlias);
                return newAlias;
            }

            AliasInfoResult result = aliases.GetAlias(AdminUsername, AdminPassword, GetDomainName(mailAliasName), mailAliasName);
            alias.Name = result.AliasInfo.Name;
            alias.ForwardTo = result.AliasInfo.Addresses[0];
            return alias;
        }
コード例 #10
0
ファイル: SmarterMail2.cs プロジェクト: jordan49/websitepanel
        public MailAlias[] GetMailAliases(string domainName)
        {
            try
            {

                svcAliasAdmin aliases = new svcAliasAdmin();
                PrepareProxy(aliases);

                AliasInfoListResult result = aliases.GetAliases(AdminUsername, AdminPassword, domainName);

                if (!result.Result)
                    throw new Exception(result.Message);

                List<MailAlias> aliasesList = new List<MailAlias>();


                foreach (AliasInfo alias in result.AliasInfos)
                {
                    if (alias.Addresses.Length == 1)
                    {
                        MailAlias mailAlias = new MailAlias();
                        mailAlias.Name = alias.Name + "@" + domainName;
                        mailAlias.ForwardTo = alias.Addresses[0];
                        aliasesList.Add(mailAlias);
                    }
                }
                return aliasesList.ToArray();
            }
            catch (Exception ex)
            {
                throw new Exception("Could not get the list of mail aliases", ex);
            }
        }
コード例 #11
0
ファイル: SmarterMail2.cs プロジェクト: jordan49/websitepanel
        public bool MailAliasExists(string mailAliasName)
        {
            try
            {
                svcAliasAdmin aliases = new svcAliasAdmin();
                PrepareProxy(aliases);

                AliasInfoResult result = aliases.GetAlias(AdminUsername, AdminPassword, GetDomainName(mailAliasName), mailAliasName);

                if ((result.AliasInfo.Name.Equals("Empty")) && (result.AliasInfo.Addresses.Length == 0))
                    return false;

                return true;
            }
            catch (Exception ex)
            {
                throw new Exception("Could not check whether mail alias exists", ex);
            }
        }
コード例 #12
0
		public MailGroup[] GetGroups(string domainName)
		{
			try
			{
				svcAliasAdmin svcGroups = new svcAliasAdmin();
				PrepareProxy(svcGroups);

				AliasInfoListResult result = svcGroups.GetAliases(AdminUsername, AdminPassword, domainName);

				if (!result.Result)
					throw new Exception(result.Message);


				List<MailGroup> groups = new List<MailGroup>();

				foreach (AliasInfo alias in result.AliasInfos)
				{
					//group - alias with more than one forwarding address
					if (alias.Addresses.Length > 1)
					{
						MailGroup mailGroup = new MailGroup();
						mailGroup.Name = alias.Name + "@" + domainName;
						mailGroup.Members = alias.Addresses;
						groups.Add(mailGroup);
					}
				}

				return groups.ToArray();
			}
			catch (Exception ex)
			{
				throw new Exception("Could not get the list of mail domain groups", ex);
			}
		}
コード例 #13
0
		public MailAlias GetMailAlias(string mailAliasName)
		{
			svcAliasAdmin aliases = new svcAliasAdmin();
			PrepareProxy(aliases);


			MailAlias alias = new MailAlias();
			MailAlias newAlias = new MailAlias();

			//convert old alliases created as mailboxes
			if (!MailAliasExists(mailAliasName))
			{
				MailAccount account = GetAccount(mailAliasName);
				newAlias.Name = account.Name;
				if ((account.ForwardingAddresses != null) && (account.ForwardingAddresses.Length > 0))
				{
					newAlias.ForwardTo = account.ForwardingAddresses[0];
				}
				else
				{
					newAlias.ForwardTo = string.Empty;
				}
				DeleteAccount(mailAliasName);
				CreateMailAlias(newAlias);
				return newAlias;
			}

			AliasInfoResult result = aliases.GetAlias(AdminUsername, AdminPassword, GetDomainName(mailAliasName), mailAliasName);
			alias.Name = result.AliasInfo.Name;
			if ((result.AliasInfo.Addresses != null) && (result.AliasInfo.Addresses.Length > 0))
			{
				alias.ForwardTo = result.AliasInfo.Addresses[0];
			}
			else
			{
				alias.ForwardTo = "*****@*****.**";
			}
			return alias;
		}