Images in news mails

Поиск
Список
Период
Сортировка
От Tobias Bussmann
Тема Images in news mails
Дата
Msg-id 99A6E7C8-1634-4162-96FD-D5AC404ADBCF@gmx.net
обсуждение исходный текст
Ответы Re: Images in news mails
Список pgsql-www
Ever since HTML emails were introduced for project news in around 2020, I have wondered why, on my system (macOS using
AppleMail as the MUA), emails were sometimes displayed in a distorted way. Today, I took the time to track it down.
AppleMail 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
affectsthe 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
furthertesting and refactoring to support regular and inline attachments simultaneously. I don't feel confident enough
todo 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
attachingthe 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>


Вложения

В списке pgsql-www по дате отправления: