Brian Dunning's FileMaker Custom Functions

IsValidEmail ( theEmail )

Determines if a supplied email address is valid or not

  Average rating: 3.6 (68 votes) Log in to vote

Paul Turnbull   Paul Turnbull - Show more from this author
One of Me
http://www.oneofme.ca

Share on Facebook Share on Twitter

  Sample input:
IsValidEmail ( "joe@blah.com" )
  Sample output:
1

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Takes a text string a checks to see if it is a valid email address. Includes a value list of over 260 Top Level Domains that are checked against. If the string is not a valid address it returns an explanation of the why the test failed.

Will not handle urls in the form "contact@domain.com/some.name" although you could edit to handle this if you like.

Edited 11/13/05 - fixed bugs.

 

Comments

Benka   Benka, Rennes, France
Jun 3, 2009
Hello Paul,

Thank you for the function.

Little bug :

ééééé@text.com return true

text text@text.com return true

text@text.com-- return true
 
Benka   Benka, Rennes, France
Jun 3, 2009
text @text.com return true
 
Jamie Thompson, Computech IT Services Ltd.   Jamie Thompson, Computech IT Services Ltd., Plymouth, UK
Mar 10, 2011
Great function. However, he ampersand (&) is a valid character in an email address.
 
Marc   Marc, San Diego, CA
Mar 11, 2011
Naming the function "IsValidEmail" in FileMaker 11 conflicts with an internal existing function name.

Maybe rename to "IsThisValidEmail"?
Anyway, thank you and I like this function very much.
 
Dennis   Dennis, JC Raulston Arboretum
Aug 24, 2020
According to RFC2696 (http://tools.ietf.org/html/rfc3696) the local-part of an email can contain several of the characters that the code above declares invalid. To quote from the RFC:
"Without quotes, local-parts may consist of any combination of
alphabetic characters, digits, or any of the special characters

! # $ % & ' * + - / = ? ^ _ ` . { | } ~

period (".") may also appear, but may not be used to start or end the
local part, nor may two or more consecutive periods appear. Stated
differently, any ASCII graphic (printing) character other than the
at-sign ("@"), backslash, double quote, comma, or square brackets may
appear without quoting. If any of that list of excluded characters
are to appear, they must be quoted."
 
Dan Shockley   Dan Shockley
Jan 3, 2023
Here's an updated version that also includes ideas by Michael Rhodes (see https://www.briandunning.com/cf/972).
This version separates out some of the tests, adds more allowed local-part characters (but not all, as explained in the function's comments), and gives up trying to test for "real" TLDs, since that list is ever-growing. As Michael Rhodes suggested, it just tests for domain-part syntax-validity.

// Email_FormatValidityTest ( someEmail )
// version 2023-01-03

/*

Returns an "email address is valid" if the specified email is syntactically valid.
Returns a descriptive error message if something invalid is found.
Updated version of a function by Paul Turnbull, with some input from another function by Michael Rhodes.

LINKS:
RFC 3696: https://www.rfc-editor.org/rfc/rfc3696#page-5
Turnbull function: https://www.briandunning.com/cf/360
Rhodes function: https://www.briandunning.com/cf/972

HISTORY:
2023-01-03 ( danshockley ): Created. Based on function by Paul Turnbull.

*/


Let ( [
alphanum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
; dotChar = "."
; validChars_Domain = alphanum & "-" & dotChar
; validSpecialChars_Local = "!#$%&'*+-/=?^_`{|}~" /* RFC 3696, 5322 */
/* Technically, the following characters should ALSO be allowed, if properly quoted/escaped:
"(),:;<>@[]"
& Char ( 92 ) // back slash
& Char ( 34 ) // double quote
However, this function does not (yet) allow them to reduce complexity of checking validity,
which would involve checking quote/escape syntax, as well as the rarity of these characters being used.
*/
; validChars_Local = alphanum & dotChar & validSpecialCh
 
Dan Shockley   Dan Shockley
Jan 3, 2023
Well, that got truncated. So, I uploaded my new version, since I gave it a new name anyway.
Here's a link to Email_FormatValidityTest: https://www.briandunning.com/cf/2632
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: