TROUBLESHOOTING

Why your HTML file won’t open when you email it

Security warnings, blank screens, raw source code on phones — the specific reasons emailed HTML files fail, and what to do instead.

3 min read·

You attached an HTML file, they said it did not work, and you cannot reproduce it because on your machine it opens perfectly. Here is what is going on at their end.

Mail providers treat HTML attachments as dangerous

HTML attachments are a long-running phishing technique — an attacker sends a file that renders a convincing login form locally, sidestepping the URL checks that would otherwise flag it. Providers responded by warning about, sandboxing, or outright stripping them.

So depending on the recipient’s provider, your file may arrive with a red warning banner, land in spam, or never arrive at all. None of these are things you can fix from the sending side.

Phones mostly have nowhere to put it

This is the biggest one in practice. iOS and Android have no strong default handler for a downloaded .html file. Tapping it often opens a text viewer showing your raw markup, or does nothing at all.

Since most people read most messages on a phone, "just open the attachment" fails for the majority of your recipients before any of your content is involved.

file:// breaks things that worked locally

Even when the file opens in a desktop browser, it loads from a file:// URL rather than over HTTP, and browsers restrict what such a page can do. Fetch requests fail on CORS grounds, some module scripts refuse to load, and anything using local storage behaves inconsistently.

Relative links to images or stylesheets also break the moment the file is separated from its folder, which is exactly what an email attachment does.

The fix is a link, not a better attachment

Host the file and send a URL. A hosted page arrives over HTTPS, opens in the browser your recipient already has, works on phones, unfurls with a preview in chat apps, and has none of the restrictions that file:// imposes.

The fast version: upload the file to FileShare Pro, copy the link, paste it in your message. Free plan, no credit card, and you can replace the file later without the link changing.

Frequently asked

Why does Gmail warn about my HTML attachment?

HTML attachments are widely used in phishing because they can render a fake login page locally, bypassing URL reputation checks. Mail providers therefore warn on, sandbox, or strip them regardless of what your file actually contains.

Why does my HTML file show as code on a phone?

Mobile operating systems have no reliable default handler for a downloaded .html file, so many open it in a plain text viewer instead of a browser. Sending a hosted link avoids the problem entirely.

Can I zip the file so it survives email?

A zip usually gets through, but it makes the recipient’s experience worse: they must download, extract, find the file, and open it — and on a phone that chain typically breaks anyway. A link is both more reliable and less work for them.

Got a page to share?

Drop the file, copy the link — live in seconds, free plan included.

Start sharing free