System Administration & Network Administration
email email-server
Updated Wed, 29 Jun 2022 18:11:03 GMT

Does the email size limit include the size of the body?


(If there is a better place to ask this, let me know.)

A lot of email servers limit the combined size of files attached to incoming emails. Like, for example, maybe some email server disallows messages larger than 20MB; it would fail if an attachment is 22MB, and it would also fail if one attachment is 10MB and a second attachment is 12MB. Most email servers implement some sort of limit like this example, but the total allowed size varies depending on which.

Here's the part I don't understand though - does that size limit only apply to attachments? or does it apply to the total size of the email? Like, lets say that a hypothetical email has an attachment that is exactly 19.98MB. But, the body of the email message is 0.03MB. Assuming that the receiving email server has a limit of 20MB, would that arrive? or fail to arrive? Or maybe whether that particular example succeeds or fails depending on which email server is hypothetically receiving it?




Solution

Technically, there is no difference between the message body and the attachments. Both the body and the attachments are equally parts of a multipart or multipurpose email message, as defined in RFC 2045.

The message size limits are typically against the total length of the message including all the parts and the headers. Such limit can also be advertised with a Message Size Declaration reply to the EHLO command, and the RFC 1870 also provides a definition for the size limit in section 5:

The message size is defined as the number of octets, including CR-LF pairs, but not the SMTP DATA command's terminating dot or doubled quoting dots, to be transmitted by the SMTP client after receiving reply code 354 to the DATA command.

The fixed maximum message size is defined as the message size of the largest message that a server is ever willing to accept. An attempt to transfer any message larger than the fixed maximum message size will always fail.

This is, e.g., implemented in both Postfix and Exim with message_size_limit configuration parameter; Microsoft Exchange has multiple types of message size limits.

Also notice that binary attachments must be converted to 7-bit ASCII text. Base64 encoding is used for this, causing 37% overhead (33% by the encoding itself; 4% more by the inserted line breaks; RFC 2045, 6.8). For this reason you may not be able to send attachments despite they are smaller than the limit.





Comments (5)

  • +1 – I cannot estimate how common those are, but additional anti-DoS-motivated limitations on number and inflated size of nested & compressed attachments will further complicate a simple description of an effective "size limit". — Jun 24, 2022 at 21:35  
  • +3 – That's true, but also a bit far from the original question which is about sending legitimate mail with more typical attachments. — Jun 25, 2022 at 06:00  
  • +0 – MIME requires line breaks at-least every 76 characters so 37% (21÷57) is the minimum size expansion — Jun 26, 2022 at 01:11  
  • +1 – @Jasen: According to RFC 5322, 2.3 "Lines of characters in the body MUST be limited to 998 characters, and SHOULD be limited to 78 characters, excluding the CRLF." Therefore, 76 characters is not a hard requirement, making the overhead more varying than that. — Jun 26, 2022 at 10:02  
  • +1 – @EsaJokinen read the section toy pointed me to againt, then check out datatracker.ietf.org/doc/html/rfc2045#section-6.8 - and search for the string 76 on page 24 — Jun 29, 2022 at 08:13