woot586
woot586

Reputation: 3965

Is it standard practice to block or allow email addresses with a ‘+’ in?

I want each user to register with a unique email address. However some email addresses like GMail allow you to add a + suffix which could be used to register multiple accounts to a website but it all goes to a single email address e.g.

Effectively they can have as many email addresses as they want. This is a problem because my website sees it as 5 separate email addresses but gmail sees it as one email address.

I was thinking of blocking any email addresses with a ‘+' in, but I don’t want to block any valid email addresses. What is the standard practice?

Upvotes: 6

Views: 1669

Answers (2)

kba
kba

Reputation: 19466

I don't think there is a standard practice on how to handle this, other than not allowing + all together. On the other hand, preventing it doesn't seem to be that useful. It won't take more than a few minutes to create an entirely new e-mail address on some free service if whoever you're intending to block-out really needs it.

It should also be noted that a lot of other e-mail providers also provide subaddressing, but not using the plus sign, but with a hyphen (Yahoo, Runbox, etc.), and attempting to block this out will only cause trouble for anybody just having an e-mail address with a hyphen in it. It's a war that you've already lost.

Besides, if you filter out plus signs, you're essentially not compliant with the RFC3696 standard anymore:

The exact rule is that any ASCII character, including control characters, may appear quoted, or in a quoted string. [...]

Without quotes, local-parts may consist of any combination of alphabetic characters, digits, or any of the special characters

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

But you could just strip out the plus part if you insist.

$emails = array('[email protected]','[email protected]','[email protected]');

foreach ($emails as &$email)
{
    list($identifier, $domain) = explode('@',$email);
    list($name) = explode('+',$identifier);
    $email = $name."@".$domain;
}
    
print_r($emails);

The above will give you

Array
(
    [0] => [email protected]
    [1] => [email protected]
    [2] => [email protected]
)

Upvotes: 5

Neo
Neo

Reputation: 7099

Email ids can contain many characters which would look incorrect to us, I found a good thread here which might answer your query: What characters are allowed in an email address?

Also to find the unique email id, just take the first half of the email id and remove + and . chars and then verify.

Upvotes: 0

Related Questions