Re: Images in news mails

From: "Jonathan S(dot) Katz" <jkatz(at)postgresql(dot)org>
To: Tobias Bussmann <t(dot)bussmann(at)gmx(dot)net>, pgsql-www(at)lists(dot)postgresql(dot)org
Subject: Re: Images in news mails
Date: 2025-09-05 18:23:16
Message-ID: 29c71778-5871-4e4d-a80e-d67351c8eb4b@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-www

On 9/4/25 3:49 PM, Tobias Bussmann wrote:
> Ever since HTML emails were introduced for project news in around 2020, I have wondered why, on my system (macOS using Apple Mail as the MUA), emails were sometimes displayed in a distorted way. Today, I took the time to track it down. Apple Mail ignores the size if the image source is provided inline via CID and not referenced externally [2, footnote 3]. As a workaround, the width can be specified again in the 'style' tag, as I have done in the attached patch.
>
> Another issue is that the Slonik logo is displayed again at the end of the email. In contrast to the first issue, this affects the Mail app on iOS as well. My analysis suggests that this is caused by the MIME structure of the email:
> - multipart/mixed
> - multipart/alternative
> - text/plain
> - text/html
> - image/png with Content-Disposition: inline
>
> This issue is resolved if I change the structure to the following:
> - multipart/alternative
> - text/plain
> - multipart/related
> - text/html
> - image/png with Content-Disposition: inline
>
> This change could be made in the send_simple_mail() function in the pgweb/mailqueue/util.py, but it would require further testing and refactoring to support regular and inline attachments simultaneously. I don't feel confident enough to do this without setting up a working test system of pgweb.
> An alternative solution could be to utilise the embed_images_in_html() function in pgweb/news/util.py instead of attaching the image to the email.
>
> With these changes applied, the mail is displayed correctly on Apple Mail [4].

This has plagued me for years, and I'm so happy you tracked this down!

The patch looks good; have you tested in a few other mail clients? I
haven't had a chance to test yet.

Thanks,

Jonathan

In response to

Responses

Browse pgsql-www by date

  From Date Subject
Next Message Magnus Hagander 2025-09-05 22:05:16 Re: Upcoming Events on front page
Previous Message Jonathan S. Katz 2025-09-05 18:21:07 Re: Upcoming Events on front page