• hslee

    (@hslee)


    Hi, guys.

    I’m using wordpress and some plug-ins.

    Does ‘is_email’ function in wordpress work well for e-mail addresses with trailing space?

    [email protected]_” -> Here ‘_’ means space.

    When I use plug-in using this ‘is_email’ function of wordpress, that plug-in regards “[email protected]_” as an invalid e-mail address.

    • This topic was modified 8 years ago by hslee.
    • This topic was modified 8 years ago by hslee.
Viewing 1 replies (of 1 total)
  • kjodle

    (@kjodle)

    that plug-in regards “[email protected]_” as an invalid e-mail address.

    Yes, because “.com_” (space) is not a valid TLD. You should probably strip the string containing the email address of any trailing spaces before you run it through is_email.

    Something like this:

    $new_address = trim( $address );
    if ( is_mail( $new_address ) ) {
        your function;
    }

    Keep in mind, the trim() function in PHP will strip whitespace from the beginning and end of a string. See this page in the PHP manual for more information.

Viewing 1 replies (of 1 total)
  • The topic ‘Does ‘is_email’ work well for e-mail addresses with trailing space?’ is closed to new replies.