public inbox for pgsql-www@postgresql.org  
help / color / mirror / Atom feed
Images in news mails
6+ messages / 3 participants
[nested] [flat]

* Images in news mails
@ 2025-09-04 19:49 Tobias Bussmann <t.bussmann@gmx.net>
  2025-09-05 18:23 ` Re: Images in news mails Jonathan S. Katz <jkatz@postgresql.org>
  2026-01-07 20:46 ` Re: Images in news mails Magnus Hagander <magnus@hagander.net>
  0 siblings, 2 replies; 6+ messages in thread

From: Tobias Bussmann @ 2025-09-04 19:49 UTC (permalink / raw)
  To: pgsql-www@lists.postgresql.org

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;



Attachments:

  [application/octet-stream] 0001-fix-display-of-images-in-apple-mail-v1.patch (1.0K, 2-0001-fix-display-of-images-in-apple-mail-v1.patch)
  download | inline diff:
From 8d94a9ee3c53c18dd3534f411ce1ae173f3db284 Mon Sep 17 00:00:00 2001
From: Tobias Bussmann <t.bussmann@gmx.net>
Date: Thu, 4 Sep 2025 21:13:57 +0200
Subject: [PATCH] fix display of images in apple mail for project news

---
 templates/news/mail/pgproject.html | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/templates/news/mail/pgproject.html b/templates/news/mail/pgproject.html
index 55ddc2a0..0c98726a 100644
--- a/templates/news/mail/pgproject.html
+++ b/templates/news/mail/pgproject.html
@@ -4,8 +4,8 @@
 
 {%block content%}
 <div>
-  <img style="float: left" height="50" width="50" src="cid:slonik.png" alt="PostgreSQL logo">
-  <img style="float: right" height="50" width="50" src="cid:slonik.png" alt="PostgreSQL logo">
+  <img style="float: left; width: 50px" height="50" width="50" src="cid:slonik.png" alt="PostgreSQL logo">
+  <img style="float: right; width: 50px" height="50" width="50" src="cid:slonik.png" alt="PostgreSQL logo">
   <h1>{{news.title}}</h1>
 </div>
 {{news.content|markdown}}
-- 
2.45.2



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Images in news mails
  2025-09-04 19:49 Images in news mails Tobias Bussmann <t.bussmann@gmx.net>
@ 2025-09-05 18:23 ` Jonathan S. Katz <jkatz@postgresql.org>
  2025-09-07 16:16   ` Re: Images in news mails Tobias Bussmann <t.bussmann@gmx.net>
  1 sibling, 1 reply; 6+ messages in thread

From: Jonathan S. Katz @ 2025-09-05 18:23 UTC (permalink / raw)
  To: Tobias Bussmann <t.bussmann@gmx.net>; pgsql-www@lists.postgresql.org

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


Attachments:

  [application/pgp-signature] OpenPGP_signature.asc (840B, 2-OpenPGP_signature.asc)
  download

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Images in news mails
  2025-09-04 19:49 Images in news mails Tobias Bussmann <t.bussmann@gmx.net>
  2025-09-05 18:23 ` Re: Images in news mails Jonathan S. Katz <jkatz@postgresql.org>
@ 2025-09-07 16:16   ` Tobias Bussmann <t.bussmann@gmx.net>
  2025-09-08 08:50     ` Re: Images in news mails Magnus Hagander <magnus@hagander.net>
  0 siblings, 1 reply; 6+ messages in thread

From: Tobias Bussmann @ 2025-09-07 16:16 UTC (permalink / raw)
  To: Jonathan S. Katz <jkatz@postgresql.org>; pgsql-www@lists.postgresql.org

Am 05.09.2025 um 20:23 schrieb Jonathan S. Katz <jkatz@postgresql.org>:
> This has plagued me for years, and I'm so happy you tracked this down!

I'm happy to hear, I'm not the only one seeing this. Glad to help!


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

I haven't tried other mail clients myself, but as the style definition is just redundant to the img attributes, I wouldn't expect any regression by this. But HTML emails are full of miracles ;)

Litmus.com has become quite expensive for render previews, so I looked for alternatives. I found Testi.at, which offers some free tests at least. Unfortunately, I was unable to provide the full MIME structure there and thus could not simulate the CID-referenced image that causes the problem in Apple Mail. When I experimented with an externally hosted image, the result looked good in the provided previews. However, I visually identified another issue: Outlook does not seem to support the 'float' style attribute [1 footnote 1]. In the v2 patch, I implemented a workaround to duplicate the 'float' style using an 'align' img attribute. Previews of the resulting rendering can be found at [2].

Best
Tobias

[1]: <https://www.caniemail.com/search/?s=float;
[2]: <https://testi.at/proj/7oveul95szn3cz5as6;



Attachments:

  [application/octet-stream] 0001-fix-display-of-images-in-apple-mail-v2.patch (1.1K, 2-0001-fix-display-of-images-in-apple-mail-v2.patch)
  download | inline diff:
From e122fcdda1a96b79f10f44edd3c939c4d79a0ae3 Mon Sep 17 00:00:00 2001
From: Tobias Bussmann <t.bussmann@gmx.net>
Date: Thu, 4 Sep 2025 21:13:57 +0200
Subject: [PATCH] fix display of images in project news for apple mail and
 outlook

---
 templates/news/mail/pgproject.html | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/templates/news/mail/pgproject.html b/templates/news/mail/pgproject.html
index 55ddc2a0..c6c01006 100644
--- a/templates/news/mail/pgproject.html
+++ b/templates/news/mail/pgproject.html
@@ -4,8 +4,8 @@
 
 {%block content%}
 <div>
-  <img style="float: left" height="50" width="50" src="cid:slonik.png" alt="PostgreSQL logo">
-  <img style="float: right" height="50" width="50" src="cid:slonik.png" alt="PostgreSQL logo">
+  <img style="float: left; width: 50px" height="50" width="50" align="left" src="cid:slonik.png" alt="PostgreSQL logo">
+  <img style="float: right; width: 50px" height="50" width="50" align="right" src="cid:slonik.png" alt="PostgreSQL logo">
   <h1>{{news.title}}</h1>
 </div>
 {{news.content|markdown}}
-- 
2.50.1



  [application/pgp-signature] signature.asc (833B, 3-signature.asc)
  download

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Images in news mails
  2025-09-04 19:49 Images in news mails Tobias Bussmann <t.bussmann@gmx.net>
  2025-09-05 18:23 ` Re: Images in news mails Jonathan S. Katz <jkatz@postgresql.org>
  2025-09-07 16:16   ` Re: Images in news mails Tobias Bussmann <t.bussmann@gmx.net>
@ 2025-09-08 08:50     ` Magnus Hagander <magnus@hagander.net>
  2025-12-02 21:30       ` Re: Images in news mails Magnus Hagander <magnus@hagander.net>
  0 siblings, 1 reply; 6+ messages in thread

From: Magnus Hagander @ 2025-09-08 08:50 UTC (permalink / raw)
  To: Tobias Bussmann <t.bussmann@gmx.net>; +Cc: Jonathan S. Katz <jkatz@postgresql.org>; pgsql-www@lists.postgresql.org

On Sun, Sep 7, 2025 at 6:16 PM Tobias Bussmann <t.bussmann@gmx.net> wrote:

> Am 05.09.2025 um 20:23 schrieb Jonathan S. Katz <jkatz@postgresql.org>:
> > This has plagued me for years, and I'm so happy you tracked this down!
>
> I'm happy to hear, I'm not the only one seeing this. Glad to help!
>

What's more amazing is that AFAIK this is the first time *anyone* has
reported this to be a problem. And it's been this way since 2020...

It is also slightly ironic that it's apple mail that's seeing the problem,
given it's quite overrepresented in *generating* broken attachments in
similar ways when you look in the archive :)


> The patch looks good; have you tested in a few other mail clients? I
> haven't had a chance to test yet.
>
> I haven't tried other mail clients myself, but as the style definition is
> just redundant to the img attributes, I wouldn't expect any regression by
> this. But HTML emails are full of miracles ;)
>

Indeed it does. For example, you mentioned the possibility of embedding the
image instead of attaching - that *does* break multiple clients, I think at
least Outlook and maybe also gmail.



> Litmus.com has become quite expensive for render previews, so I looked for
> alternatives. I found Testi.at, which offers some free tests at least.
> Unfortunately, I was unable to provide the full MIME structure there and
> thus could not simulate the CID-referenced image that causes the problem in
> Apple Mail. When I experimented with an externally hosted image, the result
> looked good in the provided previews. However, I visually identified
> another issue: Outlook does not seem to support the 'float' style attribute
> [1 footnote 1]. In the v2 patch, I implemented a workaround to duplicate
> the 'float' style using an 'align' img attribute. Previews of the resulting
> rendering can be found at [2].
>
>
PGEU does have a subscription to a service that could be used for testing.
We'd need to adapt the test instance of the website for it, but that's
fairly easy to do.

I'll also see if I can dig out my old notes for how we ended up in this
stricture in the first place, because it did go back and forth a bunch
before actually merged.

//Magnus


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Images in news mails
  2025-09-04 19:49 Images in news mails Tobias Bussmann <t.bussmann@gmx.net>
  2025-09-05 18:23 ` Re: Images in news mails Jonathan S. Katz <jkatz@postgresql.org>
  2025-09-07 16:16   ` Re: Images in news mails Tobias Bussmann <t.bussmann@gmx.net>
  2025-09-08 08:50     ` Re: Images in news mails Magnus Hagander <magnus@hagander.net>
@ 2025-12-02 21:30       ` Magnus Hagander <magnus@hagander.net>
  0 siblings, 0 replies; 6+ messages in thread

From: Magnus Hagander @ 2025-12-02 21:30 UTC (permalink / raw)
  To: Tobias Bussmann <t.bussmann@gmx.net>; +Cc: Jonathan S. Katz <jkatz@postgresql.org>; pgsql-www@lists.postgresql.org

On Mon, 8 Sept 2025 at 10:50, Magnus Hagander <magnus@hagander.net> wrote:

>
>
> On Sun, Sep 7, 2025 at 6:16 PM Tobias Bussmann <t.bussmann@gmx.net> wrote:
>
>> Am 05.09.2025 um 20:23 schrieb Jonathan S. Katz <jkatz@postgresql.org>:
>> > This has plagued me for years, and I'm so happy you tracked this down!
>>
>> I'm happy to hear, I'm not the only one seeing this. Glad to help!
>>
>
> What's more amazing is that AFAIK this is the first time *anyone* has
> reported this to be a problem. And it's been this way since 2020...
>
> It is also slightly ironic that it's apple mail that's seeing the problem,
> given it's quite overrepresented in *generating* broken attachments in
> similar ways when you look in the archive :)
>
>
> > The patch looks good; have you tested in a few other mail clients? I
>> haven't had a chance to test yet.
>>
>> I haven't tried other mail clients myself, but as the style definition is
>> just redundant to the img attributes, I wouldn't expect any regression by
>> this. But HTML emails are full of miracles ;)
>>
>
> Indeed it does. For example, you mentioned the possibility of embedding
> the image instead of attaching - that *does* break multiple clients, I
> think at least Outlook and maybe also gmail.
>

I have pushed the patch that adds the extra attributes now. Somehow I
thought I had to review a more complex patch and.. Put it off :)



>> Litmus.com has become quite expensive for render previews, so I looked
>> for alternatives. I found Testi.at, which offers some free tests at least.
>> Unfortunately, I was unable to provide the full MIME structure there and
>> thus could not simulate the CID-referenced image that causes the problem in
>> Apple Mail. When I experimented with an externally hosted image, the result
>> looked good in the provided previews. However, I visually identified
>> another issue: Outlook does not seem to support the 'float' style attribute
>> [1 footnote 1]. In the v2 patch, I implemented a workaround to duplicate
>> the 'float' style using an 'align' img attribute. Previews of the resulting
>> rendering can be found at [2].
>>
>>
> PGEU does have a subscription to a service that could be used for testing.
> We'd need to adapt the test instance of the website for it, but that's
> fairly easy to do.
>

Been testing one with that. But in that service now *all* our emails are
broken on *all* MUAs, so it's not really working... I've filed a bug with
them, we will see if they can figure it out.

-- 
 Magnus Hagander
 Me: https://www.hagander.net/ <http://www.hagander.net/;
 Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/;


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Images in news mails
  2025-09-04 19:49 Images in news mails Tobias Bussmann <t.bussmann@gmx.net>
@ 2026-01-07 20:46 ` Magnus Hagander <magnus@hagander.net>
  1 sibling, 0 replies; 6+ messages in thread

From: Magnus Hagander @ 2026-01-07 20:46 UTC (permalink / raw)
  To: Tobias Bussmann <t.bussmann@gmx.net>; +Cc: pgsql-www@lists.postgresql.org

On Thu, 4 Sept 2025 at 21:49, Tobias Bussmann <t.bussmann@gmx.net> 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
>
>
Wow, this was a lot of fun. Not.

I have changed the code to restructure like this and it mostly works. It
now breaks in the gmail app on android when connected to our company
emulated-exchange interface. But it fixes apple mail. I think there are a
lot more apple mail out there, so I think it's a strict improvement :)

Thanks for the diagnosing work! I hope this does properly fix it!

//Magnus


^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2026-01-07 20:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-09-04 19:49 Images in news mails Tobias Bussmann <t.bussmann@gmx.net>
2025-09-05 18:23 ` Jonathan S. Katz <jkatz@postgresql.org>
2025-09-07 16:16   ` Tobias Bussmann <t.bussmann@gmx.net>
2025-09-08 08:50     ` Magnus Hagander <magnus@hagander.net>
2025-12-02 21:30       ` Magnus Hagander <magnus@hagander.net>
2026-01-07 20:46 ` Magnus Hagander <magnus@hagander.net>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox