• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "Spec for email address validation?"

Collapse

  • Hiram King Of Tyre
    replied
    Thanks guys

    Leave a comment:


  • NickFitz
    replied
    Originally posted by DiscoStu View Post
    NickFitz is awarded one million Zimbabwean Xeno geek points.

    (The value of your geek points may go up as well as down and you may get back less than the number of Zimbabwean Xeno geek points you originally invested. DiscoStu is in no way authorised to award Xeno geek points whether they're Zimbabwean or not, these are a novelty item and must not be used for any illegal or immoral purposes.)

    Leave a comment:


  • DiscoStu
    replied
    NickFitz is awarded one million Zimbabwean Xeno geek points.

    (The value of your geek points may go up as well as down and you may get back less than the number of Zimbabwean Xeno geek points you originally invested. DiscoStu is in no way authorised to award Xeno geek points whether they're Zimbabwean or not, these are a novelty item and must not be used for any illegal or immoral purposes.)

    Leave a comment:


  • DimPrawn
    replied
    Below is the Regex I use with C# for email. Works for 99.99% of email addresses.

    Code:
    private const string EMAIL_ADDRESS_REGEX = @"^(([^<>()[\]\\.,;:\s@\""]+" 
    			+ @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@" 
    			+ @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" 
    			+ @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+" 
    			+ @"[a-zA-Z]{2,}))$";

    Leave a comment:


  • NickFitz
    replied
    Originally posted by Hiram King Of Tyre View Post
    All I want to do is specify what checks we should reasonably undertake to check that an email address a user enters looks valid. i.e it has an @ a . after the @ and doesn't contain spaces or other characters that are 'illegal' I don't care whether the email address actually exists or DNS lookup will actually work.
    Simply state that it should be compliant with RFC 2822 section 3.4. That's how the IETF say it should be done, therefore, that's how it should be done.

    If you need to spell it out for them, then you need (at a minimum) to quote the following:

    Code:
    addr-spec       =       local-part "@" domain
    local-part      =       dot-atom / quoted-string
    domain          =       dot-atom / domain-literal
    domain-literal  =       [CFWS] "[" *([FWS] dcontent) [FWS] "]" [CFWS]
    dcontent        =       dtext / quoted-pair
    dtext           =       NO-WS-CTL /     ; Non white space controls
                            %d33-90 /       ; The rest of the US-ASCII
                            %d94-126        ;  characters not including "[",
                                            ;  "]", or "\"
    atext           =       ALPHA / DIGIT / ; Any character except controls,
                            "!" / "#" /     ;  SP, and specials.
                            "$" / "%" /     ;  Used for atoms
                            "&" / "'" /
                            "*" / "+" /
                            "-" / "/" /
                            "=" / "?" /
                            "^" / "_" /
                            "`" / "{" /
                            "|" / "}" /
                            "~"
    atom            =       [CFWS] 1*atext [CFWS]
    dot-atom        =       [CFWS] dot-atom-text [CFWS]
    dot-atom-text   =       1*atext *("." 1*atext)
    text            =       %d1-9 /         ; Characters excluding CR and LF
                            %d11 /
                            %d12 /
                            %d14-127
    quoted-pair     =       ("\" text)
    NO-WS-CTL       =       %d1-8 /         ; US-ASCII control characters
                            %d11 /          ;  that do not include the
                            %d12 /          ;  carriage return, line feed,
                            %d14-31 /       ;  and white space characters
                            %d127
    FWS             =       ([*WSP CRLF] 1*WSP) /   ; Folding white space
                            obs-FWS
    
    ctext           =       NO-WS-CTL /     ; Non white space controls
    
                            %d33-39 /       ; The rest of the US-ASCII
                            %d42-91 /       ;  characters not including "(",
                            %d93-126        ;  ")", or "\"
    
    ccontent        =       ctext / quoted-pair / comment
    
    comment         =       "(" *([FWS] ccontent) [FWS] ")"
    
    CFWS            =       *([FWS] comment) (([FWS] comment) / FWS)
    (I think that's complete, but you'll have to check against the spec.)
    Last edited by NickFitz; 17 October 2008, 13:55. Reason: Oops, missed a bit

    Leave a comment:


  • TheFaQQer
    replied
    Originally posted by Hiram King Of Tyre View Post
    Crikey...

    All I want to do is specify what checks we should reasonably undertake to check that an email address a user enters looks valid. i.e it has an @ a . after the @ and doesn't contain spaces or other characters that are 'illegal' I don't care whether the email address actually exists or DNS lookup will actually work.
    IIRC, there is some simple code in php that you can call to do a domain lookup, which is what my website does. I couldn't be bothered to work out what the appropriate checks were, but if there is something that does it easily, then I'll use that

    Leave a comment:


  • Hiram King Of Tyre
    replied
    Crikey...

    All I want to do is specify what checks we should reasonably undertake to check that an email address a user enters looks valid. i.e it has an @ a . after the @ and doesn't contain spaces or other characters that are 'illegal' I don't care whether the email address actually exists or DNS lookup will actually work.

    Leave a comment:


  • TheFaQQer
    replied
    Originally posted by NickFitz View Post
    Surely that's related to verification of the address - validation, in this context, usually refers to simply ensuring that a given string is compliant with RFC 2822's specification of the format of an email address, not verifying that it is in fact an address to which mail can be delivered.
    True - I was (as ever) over delivering on the spec, and looked to make sure that the address was verified rather than just of a valid format. Is there much benefit in storing an email address that isn't verified as capable of receiving mail?

    Plus, it's easier to verify the domain against the MX lookup than to try and code whether the format of the address is valid.

    Leave a comment:


  • NickFitz
    replied
    Oh, BTW, using regular expressions isn't necessarily the most efficient way to validate the form of an email address. The following is claimed to be complete with respect to RFC 822... but RFC 2822 probably added some additional complexities that this doesn't account for:
    Code:
    (?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
    )+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:
    \r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(
    ?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ 
    \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\0
    31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\
    ](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+
    (?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:
    (?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
    |(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)
    ?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\
    r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[
     \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)
    ?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t]
    )*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[
     \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*
    )(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
    )+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)
    *:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+
    |\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r
    \n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:
    \r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t
    ]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031
    ]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](
    ?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?
    :(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?
    :\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*)|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?
    :(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?
    [ \t]))*"(?:(?:\r\n)?[ \t])*)*:(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] 
    \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|
    \\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>
    @,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"
    (?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t]
    )*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
    ".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?
    :[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[
    \]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-
    \031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(
    ?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;
    :\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([
    ^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\"
    .\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\
    ]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\
    [\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\
    r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] 
    \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]
    |\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \0
    00-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\
    .|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,
    ;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?
    :[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*
    (?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".
    \[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[
    ^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]
    ]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*)(?:,\s*(
    ?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
    ".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(
    ?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[
    \["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t
    ])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t
    ])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?
    :\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|
    \Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:
    [^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\
    ]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)
    ?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["
    ()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)
    ?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>
    @,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[
     \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,
    ;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t]
    )*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
    ".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?
    (?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".
    \[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:
    \r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\[
    "()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])
    *))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])
    +|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\
    .(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
    |(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(
    ?:\r\n)?[ \t])*))*)?;\s*)

    Leave a comment:


  • NickFitz
    replied
    Originally posted by TheFaQQer View Post
    I use an MX lookup to check that the domain is registered for receiving email.
    Surely that's related to verification of the address - validation, in this context, usually refers to simply ensuring that a given string is compliant with RFC 2822's specification of the format of an email address, not verifying that it is in fact an address to which mail can be delivered.

    Leave a comment:


  • NickFitz
    replied
    Originally posted by Hiram King Of Tyre View Post
    Yes, I found that. I'm not looking for a regular expression or technically how to carry out the validation, just what to put in a use case to ensure that the validation is carried out correctly....
    RFC 2822 is the specification, so stating that validation should conform to it really ought to be all you have to say.

    Leave a comment:


  • TheFaQQer
    replied
    I use an MX lookup to check that the domain is registered for receiving email.

    Leave a comment:


  • pmeswani
    replied
    Originally posted by Hiram King Of Tyre View Post
    Yes, I found that. I'm not looking for a regular expression or technically how to carry out the validation, just what to put in a use case to ensure that the validation is carried out correctly....
    The validation would be....

    At least 1 alphanumeric character followed by exactly 1 @ [followed by at least 1 alphanumeric character followed by 1 dot]* followed by resolving domain suffix which must be resolvable by DNS.

    The assumption is that the DNS server does have a valid MX record and that the email address is RFC compliant.

    You can sepcify various exclusions (such as no ', *, , ,#, etc.)

    * represents at least 1 iteration (in this example). Modify the wording accordingly.

    Leave a comment:


  • FiveTimes
    replied
    Originally posted by Hiram King Of Tyre View Post
    Yes, I found that. I'm not looking for a regular expression or technically how to carry out the validation, just what to put in a use case to ensure that the validation is carried out correctly....
    Just put that the address must not contain
    : ( ) < > [ ] , ; : \ / " etc.... or what ever is in the spec mentioned above.

    Leave a comment:


  • voodooflux
    replied
    Originally posted by Hiram King Of Tyre View Post
    Yes, I found that. I'm not looking for a regular expression or technically how to carry out the validation, just what to put in a use case to ensure that the validation is carried out correctly....
    Not entirely clear on what you're after, but can you not infer what you want from the article?

    Leave a comment:

Working...
X