1

Possible Duplicate:
What is the optimal length for an email address in a database?

What would you put as the length of an email address field?

In the db I look after we have nvarchar(60) but this seems arbitrary.

Is there a maximum length I can allow for or are email address lengths unbounded?

EDIT this is a dupe of
What is the optimal length for an email address in a database?

please close

1
  • 1
    Some people want to get a range of opinions from the community too. Commented Aug 20, 2009 at 11:12

4 Answers 4

16

The maximum length of an email address is 254 characters.

Every email address is composed of two parts. The local part that comes before the '@' sign, and the domain part that follows it. In "[email protected]", the local part is "user", and the domain part is "example.com".

The local part must not exceed 64 characters and the domain part cannot be longer than 255 characters.

The combined length of the local + @ + domain parts of an email address must not exceed 254 characters. As described in RFC3696 Errata ID 1690.

What is the optimal length for an email address in a database?

Sign up to request clarification or add additional context in comments.

3 Comments

thanks Ian looks like I've asked a duplicate.
[email protected] what about the foobar part? is this included in the 320 characters limit?
4

This wikipedia article contains some useful background information.

You should be safe with 256 characters.

Comments

2

Is this for storing the contents of an entire email in the database? In this case I'd use the database type text rather than char or varchar, as emails can be of arbitrary length.

4 Comments

He's probably talking about the address, not a mail body.
yes address not body i've edited question to be clearer
Wicked - I got downvoted ... Thanks whoever that was! Note that I qualified my answer based on this being the email body.
i've up voted you so you get 8 now - thanks for the response
1

Something like 64 or more, but in any case make sure that you always truncate the user input (to 64). You don't want to be missing important information (user entry) just because the email was longer than you expected.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.