News for hackers. Stuff that matters.
Re:Is_email() by Macha on Wednesday February 22, 2023 @06:47PM (#34904813)
Email regex: (.*)@(.*)

If you need anything more specific the best bet is to try send an email to it.

Re:Is_email() by johannes1234321 on Wednesday February 22, 2023 @07:15PM (#34905043)
I would filter out at least whitespaces and comma. Aside from catching typos this also protects against header injection or spam abusenby sending to multiple recipients.

And yes, those should be defended when constructing the mail, but checking early doesn't cost much.

Re:Is_email() by gnabgib on Wednesday February 22, 2023 @08:10PM (#34905486)
White space and comma are allowed in the local part (left of @), as long as it's surrounded by quotes [https://en.wikipedia.org/wiki/Email_address#Local-part] [https://www.rfc-editor.org/rfc/rfc5322#section-3.2.4]
Re:Is_email() by kentonv on Wednesday February 22, 2023 @09:37PM (#34906010)
Has anyone ever seen a quoted local part though?

Honest question! I'd love to hear the details of any specific case where one has ever been used.

Re:Is_email() by gorm on Wednesday February 22, 2023 @07:25PM (#34905117)
Nearly correct. You should also do a DNS lookup on $2 and check if it has either a MX record or an A record before trying to send it.
Re:Is_email() by hn_throwaway_99 on Wednesday February 22, 2023 @07:31PM (#34905171)
Re:Is_email() by gorm on Thursday February 23, 2023 @02:44AM (#34907958)
It looks like it only check for a MX, but email could might be delivered with just an A record and without a MX record I think.
Re:Is_email() by lokedhs on Wednesday February 22, 2023 @09:33PM (#34905985)
I do almost exactly that, but I replace the stars with plus. I don't think empty name or domain parts are legal?
Re:Is_email() by alxmng on Thursday February 23, 2023 @01:25AM (#34907442)
Should be /^[^@]+@[^@]+$/ at least, because you need something before and after @
Re:Is_email() by etu on Thursday February 23, 2023 @03:42AM (#34908315)
It's allowed to have @ as part of the local part if it's quoted. So that wouldn't match my email `"foo@bar"@example.org`
Re:Is_email() by gaws on Thursday February 23, 2023 @12:18PM (#34913426)
Breasts with a chest tattoo.