/// <summary>
        /// Verifies an email address is correctly formatted with valid tlds
        /// </summary>
        /// <param name="text">email to test</param>
        /// <returns>True if the format is valid</returns>
        public static bool ValidEmailTlds(String text)
        {
            if (IsEmpty(text))
            {
                return(false);
            }
            Regex re = new Regex(@"^[A-Za-z0-9][\w\.\-]+@[A-Za-z0-9.-]+\.[A-Z_a-z]{2,}$");
            Match m  = re.Match(text.ToLower());

            if (m.Success)
            {
                int    dotPos = text.LastIndexOf(".");
                String exten  = text.Substring(dotPos + 1, text.Length - dotPos - 1);
                exten = exten.ToLower();
                if (!("|com|info|net|tv|ws|edu|org|gov|mil|us|ca|cc|cn|biz|".IndexOf("|" + exten + "|") > -1))
                {
                    return(DomainUtil.Instance().TLDList.Contains(exten));
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        // singleton method
        public static DomainUtil Instance()
        {
            lock (typeof(DomainUtil))
            {
                if (instance == null)
                {
                    instance = new DomainUtil();
                }

                return(instance);
            }
        }