Images in news mails

From: Tobias Bussmann <t(dot)bussmann(at)gmx(dot)net>
To: pgsql-www(at)lists(dot)postgresql(dot)org
Subject: Images in news mails
Date: 2025-09-04 19:49:01
Message-ID: 99A6E7C8-1634-4162-96FD-D5AC404ADBCF@gmx.net
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-www

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].

Best regards
Tobias

[1]: <https://pasteboard.co/LBjIKy2V1Woe.png>
[2]: <https://www.caniemail.com/features/html-width/>
[3]: <https://pasteboard.co/WVLPyCzYaxB9.png>
[4]: <https://pasteboard.co/UGMvMYvpMZXG.png>

Attachment Content-Type Size
0001-fix-display-of-images-in-apple-mail-v1.patch application/octet-stream 1.0 KB

Responses

Browse pgsql-www by date

  From Date Subject
Next Message Jonathan S. Katz 2025-09-04 19:50:57 Re: Wrong link on related projects
Previous Message Tobias Bussmann 2025-09-04 17:27:54 Wrong link on related projects