The inline image in html, base64, doesn't display in gmail (but does it in thunderbird)

I am sending emails from my gmail account.

I'm looking for the safest, cross-client way to send inline messages so that they all display inline images.

The problem occurs when sending html emails with embedded images: not all clients / web links display images. I am looking for a method that is either client or client.

I use python and I can control the 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 not displayed ...:

  • Thunderbird desktop client: alwasy displayed
  • gmail webmail: never displayed
  • yahoo webmail: usually
  • hotmail webmail: rare
  • firefox + chrome - as url: always displayed

I could not understand the pattern when it works and when not (except for obvious syntax or coding errors).

What i have done so far:

  • Browser URL (as indicated above - it always displays images)
  • enabled "image display" in all of these clients / web pages
  • enabled "display images from xxxx" in all these clients / web pages
  • Confirmed using the "message source" (or gmail "show original") - usually the image code is displayed.
  • copied the same code from the "view source" and checked in js fiddle
  • added coding "utf-8"
  • I tried to send images using file attachments instead of base64 embedded urls. There were other problems with this approach.
  • sending html message as UTF-8
    msgpart = MIMEText (body_html, "html", "utf-8")

  • changed the message type with a few parameters .. now it is MIMEMultipart ("alternative") - maybe there is a different format that I should use?

  • tried using CSS notation and SRG IMG notation (see above). The css version is not always supported.

(the above example is taken from Wikipedia)

You can even put this line in the URL of your browser - it works, that is, it displays an image

Does gmail smpt require special arguments? parameters?

I think if the email is displayed in thunderbird, it is probably sent correctly.

maybe

+4
source share
1 answer

As far as I know, there are no rules on how user mail agents (i.e. your email reader) should handle inline images. The "usually" results of your testing are the most disturbing.

This is not how you send them, this is how the reader selects it. There is a reason that graphic heavy emails have a link here to view as a web page because there are too many changes. I would suggest that the route or just make them multipart-mime attachments and forget trying to embed them securely.

+2
source

Source: https://habr.com/ru/post/1497772/


All Articles