Skip to content

Instantly share code, notes, and snippets.

@fsans
Last active December 13, 2023 18:10
Show Gist options
  • Save fsans/3b98b1457ae473f720441f939edba469 to your computer and use it in GitHub Desktop.
Save fsans/3b98b1457ae473f720441f939edba469 to your computer and use it in GitHub Desktop.
Validates email address according to RFC 5322, not enforcing domain and TLD length limitations imposed by SMTP

isValidEmail(email)

Let(
[
	_str = lower(email);
	_regex = "\A[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\z"

];
	email = BE_RegularExpression ( _str ; _regex )
)

/* 

Accordingly to RFC 5322, but may cover aroud 99.9% actually. 
This one does not check domain and TLD length limitations from SMTP RFC's

Created by air.fsans@gmail.com 2020

Requires BaseElements Plugin, from Goya Pty Ltd
https://docs.baseelementsplugin.com

*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment