Message formats and rendering
Rendering base64 attachments in desktop email clients
Desktop clients decode base64 MIME parts using Content-Type and Content-Disposition—broken padding or wrong types show as garbage or blocked attachments.

The decision in plain terms
Desktop email clients render base64 attachments by decoding Content-Transfer-Encoding: base64 parts and applying Content-Type plus Content-Disposition. If padding is wrong, headers disagree, or the part is inline vs attachment incorrectly, users see missing files, .dat leftovers, or unsafe-prompt dialogs. Temporary web inboxes may preview differently—never assume parity with Thunderbird, Apple Mail, or Outlook desktop.
Desktop client context and boundaries
MIME (RFC 2045–2047, 2183) lets a message carry binary payloads as ASCII-safe base64. Clients must:
- Parse multipart boundaries
- Decode transfer encoding
- Decide download vs inline display
- Apply security policy (block executables, sanitize HTML)
Mailby’s Quick Inbox focuses on safe HTML preview and code/link extraction for disposable workflows. Heavy attachment QA for your product should use clients your users actually run, plus corpus fixtures.
This article is a fixture-driven explainer for base64 attachments on desktop—not the full message-format hub.
Minimal valid fixture (working path)
Conceptual structure:
Content-Type: multipart/mixed; boundary="b1"
--b1
Content-Type: text/plain; charset=utf-8
Invoice attached.
--b1
Content-Type: application/pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="invoice.pdf"
JVBERi0xLjQKJeLjz9MKMyAwIG9iago8PC9UeXBlIC9QYWdl... (padding ==)
--b1--
Observed on a typical desktop client: paperclip, filename invoice.pdf, opens in PDF handler after decode.
Intentionally broken fixtures (failure path)
| Raw part | declared type | observed rendering | accessibility/security implication |
|---|---|---|---|
| Valid base64 PDF | application/pdf + attachment | Named PDF download | OK if user expected it |
| Truncated base64 (bad padding) | application/pdf | Error / 0-byte / refuse | User thinks sender failed |
| Valid bytes | application/octet-stream | Generic file; odd extension | Harder for screen-reader users to know type |
| Valid PDF bytes | text/plain | Garbage text window | Confusing; may leak binary in UI |
.exe base64 | application/pdf (lied) | Client may still sniff/block | Security depends on client heuristics |
Content-Disposition: inline image | image/png | Shows in body | Privacy/tracking if remote; local OK |
| UTF-8 filename encoded poorly | attachment | =?utf-8?B?...= mojibake name | Accessibility + support burden |
Counterexample: A developer tested only a web preview that displays “1 attachment” from headers without decoding. Desktop Outlook users reported corrupt files because the encoder inserted newlines incorrectly and stripped padding on a “helpful” middleware. Web UI lied; desktop told the truth.
Mechanism notes worth memorizing
- Base64 alphabet and padding (
=) matter; decoders vary in strictness. - Line length folding (76 chars) is traditional; some broken senders emit one giant line—most modern clients tolerate it.
filenamevsfilename*(RFC 5987 / 2231 style) affects non-ASCII names.- Multipart/related vs mixed changes inline image behavior.
- PGP/S/MIME wrappers add layers; outer part may be base64 with inner MIME.
Safe practices for senders you control:
- Use a maintained MIME library; do not hand-roll base64 for attachments
- Set accurate
Content-Type - Prefer
attachmentfor non-body files - Virus-scan in your pipeline; do not rely on client prompts alone
- Test at least one Windows and one macOS desktop client
Concrete worked example
Goal: Confirm your app’s “email PDF receipt” path.
- Generate message in staging with known PDF sha256.
- Deliver to a desktop client profile used for QA.
- Save attachment; hash must match.
- Mutate fixture: delete final
=padding; confirm client error path is understandable. - Mutate
Content-Typetotext/plain; document observed UX for support docs.
For disposable receiving while developing templates, /inbox can show that a part arrived; still re-check on desktop before release. Companion ops article: DNS/TLS inbound runbook. Security posture: /security.
Alternatives and when durable mailboxes matter
- Dedicated QA mailboxes on desktop clients — best fidelity
- Mime-parsing unit tests in CI — catch encoder regressions before UI
- Temporary inbox — quick “did SMTP accept and store parts?” smoke test
- Durable mailbox — when attachments are legal records you must retain
Use permanent storage policies for invoices you are obligated to keep; temporary retention clocks (/data-retention) are the wrong archive.
Short answers
What causes base64 attachment issues on desktop clients?
Header/body mismatches, corrupt encoding, and client security policies.
What should I do first?
Validate MIME with a library and compare decoded hash to source file on a real desktop client.
When is a permanent address safer?
When attachments are records (tax, contracts, HR).
What evidence changes the recommendation?
Your users are webmail-only and you already test those engines—still sample one desktop if enterprise seats exist.
Encoder checklist for application developers
When your Next.js/Laravel/Rails app attaches files:
- Use the provider’s attachment API (bytes + filename + content type) when possible—let them MIME-encode
- If you build raw MIME, use a maintained library
- Never concatenate base64 by hand in template strings
- Prefer
application/pdfetc. over generic octet-stream when known - Sanitize filenames (no path segments, control chars)
- Cap attachment size; test client limits
Desktop client matrix (what to sample)
At minimum before release:
- Outlook for Windows (Microsoft 365 account)
- Apple Mail on current macOS
- Thunderbird on one Linux or Windows box
Note quirks: Outlook may winmail.dat in misconfigured Exchange paths; Apple Mail may inline what others treat as attachments; Thunderbird is strict on some corruptions.
Security: encoded does not mean safe
Base64 is encoding, not encryption. Clients may still warn on executables. Do not tell users “it’s base64 so it’s safe.” Malware distributes happily as base64 MIME. Combine secure mail gateways, user education, and least-privilege open handlers.
Accessibility implications
Filename clarity matters for screen-reader users. attachment1.bin fails. 2026-09-invoice-acme.pdf succeeds. If your client shows “winmail.dat,” support docs should explain the TNEF failure mode without blaming the user.
Temporary inbox preview caveats
Disposable web UIs may list attachment metadata without offering full download parity. For receipt QA, save from a desktop client and hash-compare. Use Quick Inbox to confirm send/receive plumbing during early development, then graduate to desktop fixtures.
Multipart nesting gotchas
Messages may be multipart/mixed containing multipart/alternative (text+html) plus an attachment part. Poor libraries accidentally base64-wrap already-encoded parts or nest boundaries incorrectly. Validate with a MIME linter or by parsing with a second library and comparing part counts.
Transport vs rendering
SMTP may accept a broken MIME message that still delivers. Acceptance ≠ renderability. Your tests must include a client render/hash step, not only a 250 OK from the ESP.
Inline images vs attachments
Marketing mail often base64-inlines images as Content-Disposition: inline with Content-ID. Desktop clients show them in-body; accessibility tree may ignore them without alt text. Do not “fix” inline images by forcing attachment disposition without design review.
Corruption from middleboxes
Secure email gateways sometimes rewrite or block attachments, replacing them with soft notices. QA on a clean path and on a gated corporate path if those are your users. Temporary consumer inboxes will not reproduce corporate gateway rewrites.
Retention and legal holds
If attachments are legal records, temporary inbox retention is inappropriate. Use durable mail with organizational retention policies. Mailby clocks: /data-retention. Security overview: /security. Smoke receive during dev: /inbox.
Differs from the message-format hub
Hub content surveys formats broadly. This page isolates base64 attachment rendering on desktop clients with fixture tables and encoder checklists for engineers shipping PDFs and similar parts.
Sample unit test idea (pseudo)
parts = parse_mime(raw)
att = parts.attachments[0]
assert att.filename == "invoice.pdf"
assert att.content_type == "application/pdf"
assert sha256(att.bytes) == KNOWN
assert att.transfer_encoding == "base64"
Run the same raw fixture through a second parser. Disagreement means your MIME is ambiguous and desktop clients will disagree too.
Add a corpus folder fixtures/mime/attachments/ with good, truncated, wrong-type, and weird-filename samples. Fail CI if encoder output stops matching the golden “good” fixture hash after decode.
When vendors send you sample messages, save the raw .eml—screenshots do not preserve transfer encodings.
Document for support: if users report winmail.dat, ask whether the sender used Outlook TNEF; that is a different failure class than base64 padding bugs.
Filename encoding examples
Prefer ASCII filenames in early tests (invoice.pdf). Then add UTF-8 names (rechnung-überweisung.pdf) and confirm filename* parameters. Clients that mishandle encoding create support tickets that look like “PDF missing” when the file is actually present under mojibake.
Also test spaces and punctuation. Some gateways rewrite spaces to underscores; your hash check should happen after download, not on the displayed name alone.
When web preview disagrees with desktop
Believe desktop for user-impacting attachment bugs if that is your audience. Use web disposable preview as an early smoke signal only. Track discrepancies in a known-issues doc so QA does not reopen the same debate every sprint.
Building a golden corpus
Create at least five .eml files committed to your app repo:
- Valid PDF attachment (known sha256)
- Truncated base64 PDF
- Wrong Content-Type
- UTF-8 filename
- Two attachments in one message
CI parses them; a nightly job opens (1) on a desktop VM if you have UI automation. When someone “improves” the encoder, corpus failures explain exactly what broke.
Store the raw bytes of the PDF separately from the .eml so you can re-encode with a candidate library and compare.
User-facing error copy
If your product emails attachments and decoding fails on your side before send, say so clearly. If send succeeds but clients fail, support needs a different macro: ask for client name/version and a raw .eml sample with PII redacted.
Temporary inboxes help developers see parts arrived; they do not replace corpus CI. Product pages: /inbox, /developers, /security.
Reader takeaway
Match the mailbox lifetime to the longest message you still need. For this article’s scenario, that rule decides temporary versus durable more reliably than any generic “always use temp mail” tip. Re-read your vendor’s security and billing emails settings after signup so the address you chose still matches the account’s real role.
Checklist closeout
Confirm frontmatter-level decisions one last time: do you still need recovery next quarter? Do you still need to reply? Do you still need attachments as records? Any yes pushes you off temporary receive-only inboxes for this job. Keep Mailby Quick Inbox for short receive tasks where purge is acceptable and session-bound access is understood.
Support escalation data to collect
When a user reports a corrupt attachment, ask for: client name and version, whether they use IMAP or Exchange, the exact filename shown, and—if they can—a redacted raw .eml. That package distinguishes padding bugs from TNEF (winmail.dat) and from gateway rewrites faster than guessing.
Sources, test date, limitations
Date: 2026-09-24. Client versions differ (Outlook cached Exchange mode vs. IMAP). Mailby safe preview is not a substitute for desktop attachment compliance testing. No claim that every client will render malformed MIME identically.
Conclusion
Base64 attachments are mundane until headers lie or encoders break. Fixtures + hash checks on real desktop clients beat optimism from a single web preview. Use Quick Inbox for smoke reception; ship only after desktop decode matches the file you meant to send.
Try it on Mailby
Open a receive-only disposable inbox when a short-lived address fits the job — session-bound, with timed purge.
