Wednesday, 19 October 2022

Base64 encoded images not displaying in iOS Mail app when larger than 13KB

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?



from Base64 encoded images not displaying in iOS Mail app when larger than 13KB

No comments:

Post a Comment