How do attachments get encoded in an email?

Still have a question, spotted an error, or have a better explanation or a source we should cite?

When you attach a file to an email, it can't travel as-is. SMTP (the protocol that delivers email) was built in the 1980s to handle plain text only, not binary files like PDFs, images, or spreadsheets. So your attachment gets converted into text before it travels, then converted back into a file when the recipient opens it.

This conversion process is called Base64 encoding. It takes the binary data of your file (the raw 1s and 0s) and translates it into a sequence of 64 printable ASCII characters (letters, numbers, and a few symbols). Every three bytes of binary data becomes four characters of text. That's why an attachment makes your email about 33% larger in transit, even though the recipient sees the original file size.

The encoding happens automatically when you attach a file. Your email client or ESP wraps the Base64-encoded data inside a MIME structure (Multipurpose Internet Mail Extensions), which is just a set of headers that tell the recipient's email client what type of file it is, what it's named, and how to decode it back into a usable file.

A typical MIME section for an attachment looks like this:

Content-Type: application/pdf; name="invoice.pdf"
Content-Disposition: attachment; filename="invoice.pdf"
Content-Transfer-Encoding: base64

JVBERi0xLjQKJeLjz9MKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL01l
ZGlhQm94IFswIDAgNjEyIDc5Ml0KL0NvbnRlbnRzIDIgMCBSCj4+CmVuZG9iago...

The recipient's email client reads those headers, knows it's dealing with a PDF, decodes the Base64 text back into binary, and saves it as a file you can open. This all happens invisibly. You attach a file, they download a file. The encoding is just the disguise it wears in transit.

One practical consequence: if you're sending emails with large attachments (say, over 5MB), you're not just sending 5MB. You're sending 6.65MB after encoding, which is why some mail servers reject oversized attachments even when the original file seems under their limit. Many ESPs cap attachment sizes at 10MB or 25MB for this reason. If you're sending large files regularly, linking to a download instead of attaching directly keeps your emails lighter and faster to deliver.

Contributors

Who worked on this answer

Every name links to their profile. Every company links to their site. Real people, real accountability.

Ask an AI · tailored to your setup

Troubleshoot my attachment issue

I read this on the Email Almanac about "How do attachments get encoded in an email": "Attachments are encoded using Base64, converting binary data into plain text so it can travel through SMTP. The encoding happens automatically and makes files about 33% larger in transit. The recipient's email client decodes the Base64 text back into the original file." Help me troubleshoot my attachment delivery issues: 1. Diagnosis questions: - Are attachments failing to send, arriving corrupted, or getting stripped by the recipient's mail server? - What file types are you attaching? (PDFs, images, ZIPs, Office docs) - What's the typical file size? (Under 1MB, 1-5MB, 5-10MB, over 10MB) - Are you sending through an ESP or your own mail server? 2. Common fixes ranked by likelihood: - If attachments are being rejected: check your ESP's size limits (most cap at 10-25MB) - If files arrive corrupted: verify the recipient's mail client supports the file type - If images don't display: you might be confusing attachments with embedded images (different process) - If certain file types get blocked: .exe, .zip, and .js files are often filtered by corporate mail servers 3. Alternative approaches: - For files over 5MB: link to cloud storage (Google Drive, Dropbox, OneDrive) instead of attaching - For images in marketing emails: embed them as inline images, don't attach - For transactional docs (invoices, receipts): attachments under 2MB usually work fine 4. Verification steps: - Send a test email to yourself with the same attachment - Check the email source/headers to confirm the MIME structure is correct - Try sending the same attachment through a different email client to isolate the issue Share details and I'll help narrow down what's breaking.

Edit the yellow boxes, then send to the AI of your choice.