inline image in html, base64, doesn't appear in gmail (but does in thunderbird)
email, email-attachments, gmail, python
Solution
To the best of my knowledge there are no rules about how Mail User Agents (i.e. your mail reader) has to treat inline images. The "usually" results in your testing are the most troubling.
It isn't how you are sending them, it's how the reader chooses to render it. There's a reason that graphics heavy emails have a click here to view as a web page link, because there is too much variation. I'd suggest that route or just making them multipart-mime attachments and forget trying to inline them reliably.
Problem
I'm sending emails from my gmail's account. I'm searching for the safest, cross-client way to send inline messages, so that all of them will display inline images. The problem occurs in emailing html with inline images: Not all clients/webmails display the images. I'm looking for a way that's either client-proof or client-specific. I'm using python, and I can control thet headers and content types etc. ``` <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" /> ``` or ``` <div style="width: 80px; height: 80px; background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAA AAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==' ) no-repeat" /> ``` With the following html code, the image is/isn't shown...: - Thunderbird desktop client: alwasy shown - gmail webmail: never shown - yahoo webmail: usually - hotmail webmail: rarely - firefox + chrome - as url: always shown I couldn't figure out a pattern as to when it works and when it doesn't, (except for obvious syntax or encoding errors). What I done so far: - trying browser URLs (as mentioned above - it always show images) - turned on "display images" in all these clients/webmails - turned on "display images from xxxx" in all these clients/webmails - confirmed with "view message source" (or gmail's "show original") - the images code is usually there. - copied the same code from the "view source" and verified in js fiddle - added "utf-8" encoding - i tried sending images using file attachments instead of inline base64 urls. THere were other issues with that approach. sending the html message as UTF-8 msgpart = MIMEText(body_html, "html", "utf-8") changed message type via several options.. now it's MIMEMultipart("alternative") - maybe there's another format I should be using? - tried using CSS notation and IMG SRC notation (see above). css version not always supported. (the above example is taken from wikipedia) It's even possible to put this line in your browser's URL - it works - i.e. displays the image Does gmail smpt requires special arguments? parameters? I guess if the email shows in thunderbird, it's probably being sent correctly. Maybe