I’m trying to send an invitation to someone to become a user of a private WordPress blog, but WP apparently doesn’t accept an apostrophe appearing in the name in the email address as valid. For example, it seems it would consider maryo’grady@hotmail.com as an invalid email address, because of the apostrophe in Mary’s surname. Has anyone else had this problem, and is there a way around it, by substituting a different character in place of the apostrophe?
1 Answer
Filter is_email
and sanitize_email
, then apply a better check:
namespace Wpse\Email;
add_filter( 'is_email', __NAMESPACE__ . '\check_mail_address', 10, 2 );
add_filter( 'sanitize_email', __NAMESPACE__ . '\check_mail_address', 10, 2 );
function check_mail_address( $result, $email )
{
return filter_var( $email, FILTER_VALIDATE_EMAIL );
}
The PHP function is still not RFC 5321 compliant, but better than the WordPress check.