/// <summary>
        /// Determines if an email has valid syntax
        /// </summary>
        /// <param name="email">the email to test</param>
        /// <param name="TLDrequired">indicates whether or not the
        /// email must end with a known TLD to be considered valid</param>
        /// <returns>boolean indicating if the email has valid syntax</returns>
        /// <remarks>
        /// Validates an email address specifying whether or not
        /// the email is required to have a TLD that is valid.
        /// </remarks>
        public static bool Valid(string email, bool TLDrequired)
        {
            //call syntax validator
            var v = new EmailAddressParser(email, TLDrequired);

            return(v.IsValid);
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the EmailSyntaxValidator
        /// </summary>
        /// <param name="email">the email to test</param>
        /// <param name="TLDrequired">indicates whether or not the
        /// email must end with a known TLD to be considered valid</param>
        /// <remarks>
        /// The initializer creates an instance of the EmailSyntaxValidator
        /// class to validate a single email. You can specify whether or not
        /// the TLD is required and should be validated.
        /// </remarks>
        public EmailAddressParser(string email, bool TLDrequired)
        {
            this.inputemail = email;
            string email1 = EmailAddressParser.Trim(EmailAddressParser.RemoveBrackets(email));

            this.account = this.domain = "";
            if (!this.ParseAddress(email1) ||
                (this.Account.Length > 64 || this.Domain.Length > (int)byte.MaxValue ||
                 !this.DomainValid(TLDrequired)) || TLDrequired && !this.DomainExtensionValid())
            {
                return;
            }
            this.syntaxvalid = true;
        }
示例#3
0
        /// <summary>
        /// Determines if an email has valid syntax
        /// </summary>
        /// <param name="email">the email to test</param>
        /// <param name="TLDrequired">indicates whether or not the 
        /// email must end with a known TLD to be considered valid</param>
        /// <returns>boolean indicating if the email has valid syntax</returns>
        /// <remarks>
        /// Validates an email address specifying whether or not
        /// the email is required to have a TLD that is valid.
        /// </remarks>
        public static bool Valid(string email, bool TLDrequired)
        {
            //call syntax validator
            var v = new EmailAddressParser(email, TLDrequired);

            return v.IsValid;
        }
示例#4
0
 /// <summary>
 /// Checks whether the given mail-address is valid.
 /// </summary>
 public static bool IsValidEMailAddress(string mail)
 {
     return(EmailAddressParser.Valid(mail, false));
 }