This is why people should write proper code to parse and validate email addresses and not use regex
regex are proper code when written competently
Assuming "competently" means "not using them when the grammar is not regular".
I don’t even try. I put my hands up and accept [anything] @ [anything]
Well, you can still check MX record for the second "anything", that should be pretty safe, right?
I don't think that's sufficient on its own. If there's a CNAME on the domain, you'd have to follow the chain of CNAMEs to find an MX record (granted, that's not very common, but I think it's valid usage)
Resolving proxy DNS servers do that for you. A successful transaction against a resolving proxy DNS server yields a complete answer with all of the alias chain and the final resource record set (or "no such name" indicator).
After you removed the comments from the second anything, and checked that it isn't a raw IPv4 or IPv6 address. jsmith@[IPv6:2001:db8::1] is a valid email address, as is jsmith@(comment)example.com.
Though you could argue that there are good reasons to disallow ip-based email addresses.
Thanks, didn't know that! E-mail is really full of surprises. :)