pez
pez

Reputation: 4235

Python HTML - Embedded email images are blank

I'm sending emails using smtplib and I'm generating an email signature that has embedded images. I used https://www.base64-image.de/ to convert several images to base64 strings, and I'm using those encoded strings like this, as part of a MIMEMultipart('mixed') message:

body = """\
<html>
...
    <img src="%s" width = "32" height = "32">
    <img src="%s" width = "32" height = "32">
    <img src="%s" width = "32" height = "32">
...
</html>""" % (encoded_string1, encoded_string2, encoded_string3)

Example of what the string variables look like:

encoded_string1 = 'data:image/png;base64,iVBORw...'

Everything in the email is sent and formatted correctly. The images are in the correct places and are the correct size. But the images in the email are blank. There is just a border around where the image should be.

I can't figure out why this is happening. https://codebeautify.org/base64-to-image-converter can decode base64 strings to an image, and I've tested my base64 strings to make sure they're correct, which they are.

If I use a website where the images are saved as the src in the img tag, it shows up correctly in the email. I don't want to do this as I don't have control over the site that hosts the images, and I don't want to create my own site to host the images if I can avoid it.

Does anyone know why they're showing up as blank in the email once it's sent? Thanks!

Upvotes: 1

Views: 1195

Answers (1)

Mysak0CZ
Mysak0CZ

Reputation: 964

May be problem with client-side support

Send a base64 image in HTML email

Upvotes: 2

Related Questions