A customer attaches a 20 MB file to a message and the server says the limit is 25 MB, yet the message is rejected as too large. Nothing is wrong with the limit or the file. The cause is encoding. Email was designed for 7-bit text, so binary attachments are converted to a text representation before transmission, and that conversion makes the data larger. Most of the time the conversion adds about one third, so a 20 MB file becomes roughly 27 MB inside the message. Understanding this overhead explains puzzling errors, helps you set realistic limits in your product and shows how to deliver large files without bouncing. This guide explains the arithmetic, the encodings involved, the way servers check limits and the practical options for reducing size. It complements size limits and MIME, MIME attachments and attachments and spam filters.
The arithmetic
Base64 represents binary data using 64 printable characters. Three input bytes (24 bits) are split into four groups of six bits, each written as one character, so four characters carry three bytes: an increase of 33.3 percent. MIME also requires that encoded lines not exceed 76 characters, so a carriage return and line feed (2 bytes) are added after every 76 characters, adding roughly another 2.6 percent. The result is a total expansion of about 1.37 times the original size.
| Original attachment | Encoded size (approx.) | Fits a 25 MB limit? | Fits a 10 MB limit? |
|---|---|---|---|
| 1 MB | 1.37 MB | Yes | Yes |
| 5 MB | 6.8 MB | Yes | Yes |
| 7 MB | 9.6 MB | Yes | Yes, narrowly |
| 8 MB | 11.0 MB | Yes | No |
| 15 MB | 20.6 MB | Yes | No |
| 18 MB | 24.7 MB | Barely, with no space for body and headers | No |
| 20 MB | 27.4 MB | No | No |
| 25 MB | 34.3 MB | No | No |
The message also contains headers, the text body, perhaps an HTML version and signatures from DKIM, adding some tens of kilobytes. When a provider advertises a 25 MB limit, the practical limit for a single attachment is therefore about 18 MB, and the real number is smaller if you attach several files, since each one is encoded separately.
Encodings you will meet
| Encoding | Used for | Overhead | Notes |
|---|---|---|---|
| 7bit | Plain ASCII text | None | Safe everywhere |
| 8bit (8BITMIME) | Text with non-ASCII bytes when both sides advertise 8BITMIME | None | Needs server support in each hop; otherwise converted |
| quoted-printable | Mostly-ASCII text with accents or HTML | Small for English; up to 3x for dense non-Latin text | Readable in raw form; lines are soft-wrapped with =. See UTF-8 in email |
| base64 | Binary attachments, images, and text in non-Latin scripts | About 37 percent | The default for files |
| binary (BINARYMIME / CHUNKING) | Raw binary transfer | None | Rarely available end to end; do not rely on it |
| uuencode | Legacy attachments | About 35 percent | Obsolete |
Text in languages such as Hindi, Japanese or Arabic is stored as multi-byte UTF-8, and a mail library may choose Base64 for the body part because it is more compact than quoted-printable for such text. HTML emails with many inline images embedded as data are particularly costly: every image is Base64-encoded and, if repeated, repeated again.
How servers check size
- SIZE extension. The server advertises a maximum in its EHLO response (
250-SIZE 26214400) and the client may declare the size inMAIL FROM ... SIZE=n. If n exceeds the limit, the server can refuse right away with 552 before any data is transferred. See SMTP extensions. - After DATA. If the client does not declare a size, the server counts bytes as they arrive and rejects after exceeding the limit.
- Different limits at different hops. Your relay may accept 50 MB while the recipient accepts 20 MB. The message is then bounced by the final server, often with 552 5.3.4 "message size exceeds fixed limit".
- Limits by provider. Typical public mailbox limits are in the range of 20 to 50 MB for the whole message, but they change; check current documentation rather than relying on memory.
- Limits in gateways and clients. Security appliances, Outlook policies and mobile clients may impose lower limits than the provider.
Reducing size
- Send a link for large files, using a file-sharing service or your own download area with expiry and access control. Keep the link on a domain with good reputation. See link reputation.
- Compress sensibly. Zip helps with text, documents and uncompressed images, but not with JPEG, MP4 or already compressed archives. Note that some filters block certain archive types; see attachments and spam.
- Optimise images. Resize to the display size, use modern compressed formats and quality settings that suit the screen. In HTML emails, host images externally instead of embedding. See image hosting.
- Convert documents to PDF with image compression, or export spreadsheets without unnecessary sheets and formatting.
- Trim the HTML. Remove unused styles and comments; Gmail clips messages whose HTML exceeds about 102 KB, so a lean template helps there too.
- Avoid duplicates. Do not attach the same file to every message in a thread; link to the first copy.
- Split a set of files into several messages if a link is not possible, keeping each below the practical limit.
For developers
- Check the size after encoding, not before. Many libraries can compute the final length; if not, multiply by 1.37 and add a margin.
- Validate attachments early and show the user a clear message: "This file is 19 MB. The maximum is about 18 MB after encoding."
- Return a specific error for 552 responses and do not retry; a retry cannot succeed. See bounce classification.
- For API-based sending, note that the request body may also carry the file Base64-encoded, so the API request can be bigger than the final message limit. Check the API documentation for the maximum request size and use upload links or hosted attachments for large files. See the API reference.
- Stream large attachments rather than loading them entirely into memory when building messages.
- Store large files outside the mail system and send a time-limited signed URL.
Explaining it to users
A short explanation in the help text prevents many tickets: "Email files are encoded for transport, which makes them about a third larger. A message with a 20 MB attachment is about 27 MB when sent, so it may exceed a 25 MB limit." Offer a recommended attachment size (for instance, "up to 15 MB total") and a simple alternative for bigger files. When a bounce arrives, translate the code into plain language: the message was too large for the recipient's server, not corrupted, and a link will solve it.
Base64 overhead is a fact of email, not a fault in your system. Plan with the 1.37 factor, send links for large files, keep templates lean and report size errors clearly, and attachment limits stop being a source of surprise.
Send through a relay with clear limits Documented size limits and detailed bounce information.
References and further reading
Frequently asked questions
Why is my attachment rejected when it is below the limit?
Attachments are Base64-encoded, which makes them about 37 percent larger, so the encoded message may exceed the limit.
How big can an attachment be for a 25 MB limit?
About 18 MB in practice, less if the message has several files or a heavy HTML body.
Does compressing help?
Yes for text and documents, but not for already compressed files such as JPEG or MP4.
What does error 552 mean?
The message exceeded the size limit of the receiving server; retrying will not help.
What is the best way to send large files?
Send a time-limited download link instead of an attachment.