0

Let's start with saying that I know that there's a different way of attaching images with the cid method.

However, I'd like to know why this issue is happening? As long as .png image I'm encoding is below approx 13KB in size, the iOS Mail app will correctly render in in the email. For the record, Outlook has no problems rendering these images no matter the size.

I'm encoding my images this way:

list_email_img.append(
        base64.b64encode(open(list_img_paths[i], "rb").read())
        .decode("utf-8")
        .replace("\n", "")
    )`

Replacing the new lines just in case, as per this question: Base64 HTML embedded images not showing when mailed

Then I build the tag this way:

    tag = f'<img alt="" src="data:image/png;base64,{list_email_img[i]}"/>

Anyone has any ideas?

LucasSeveryn
  • 5,984
  • 8
  • 38
  • 65

1 Answers1

0

Embedding images as base64 isn't widely supported, unfortunately

Please check Send a base64 image in HTML email

Anton
  • 1,432
  • 13
  • 17
  • I know that, and I saw this question you linked when I was doing my research. I'm just surprised with the weird iOS mail size limit. – LucasSeveryn Oct 21 '22 at 07:26
  • @LucasSeveryn This isn't only iOS. Gmail and others behave the same. I was facing the same issue issue recently. The only reliable way is to attach the images in the multipart data and references them via `cid`. – Zaffy Oct 24 '22 at 23:29
  • I would assume this is related to dataUrl limits - likely it's 16k of base64 url giving you about 13k of png. You just can't know and it varies: https://stackoverflow.com/a/41755526/5819. rfc2397 says it can be as small as 1k. – Tony Lee Oct 25 '22 at 00:59