tags:

views:

4197

answers:

3

How many characters are allowed to be in the subject line of Internet email? I had a scan of The RFC for email but could not see specifically how long it was allowed to be. I have a colleague that wants to programmatically validate for it.

If there is no formal limit, what is a good length in practice to suggest? Cheers,

+1  A: 

I don't believe that there is a formal limit here, and I'm pretty sure there isn't any hard limit specified in the RFC either, as you found.

I think that some pretty common limitations for subject lines in general (not just e-mail) are:

  • 80 Characters
  • 128 Characters
  • 256 Characters

Obviously, you want to come up with something that is reasonable. If you're writing an e-mail client, you may want to go with something like 256 characters, and obviously test thoroughly against big commercial servers out there to make sure they serve your mail correctly.

Hope this helps!

Ed Altorfer
There's no particular reason why 256 is any better than 250, or 300, or 372. We're long past using bytes for string lengths.
Greg Hewgill
I agree with you for practical purposes, but I think that 256 is better than some of the other options you mentioned since it is more consistent with other products.
Ed Altorfer
+11  A: 

See RFC 2822, section 2.1.1 to start.

There are two limits that this standard places on the number of characters in a line. Each line of characters MUST be no more than 998 characters, and SHOULD be no more than 78 characters, excluding the CRLF.

As the RFC states later, you can work around this limit (not that you should) by folding the subject over multiple lines.

Each header field is logically a single line of characters comprising the field name, the colon, and the field body. For convenience however, and to deal with the 998/78 character limitations per line, the field body portion of a header field can be split into a multiple line representation; this is called "folding". The general rule is that wherever this standard allows for folding white space (not simply WSP characters), a CRLF may be inserted before any WSP. For example, the header field:

       Subject: This is a test

can be represented as:

       Subject: This
        is a test

The recommendation for no more than 78 characters in the subject header sounds reasonable. No one wants to scroll to see the entire subject line, and something important might get cut off on the right.

Michael Petrotta
Not "subject header"; every message has exactly one header. It's "subject header field". Sheesh, even when people quote the standards directly, they get the terminology wrong.
bignose
+2  A: 

It might be worth noting that Outlook limits you to 255 characters :) It's pretty arbitrary.

devians