🐛 Bug Report: No margins in email templates #136

Closed
opened 2025-10-07 00:03:07 +03:00 by OVERLORD · 19 comments
Owner

Originally created by @ilyakonovalenko on GitHub.

Originally assigned to: @kmendell on GitHub.

Reproduction steps

I noticed there are no margins in the email templates. So the email looks bad:

Image

The solution may be background removal (so let's make it white) or top and bottom margings.

Expected behavior

Top and bottom margins.

Actual Behavior

No top and bottom margins so the content box looks bad.

Version and Environment

v1.5.0

Log Output

No response

Originally created by @ilyakonovalenko on GitHub. Originally assigned to: @kmendell on GitHub. ### Reproduction steps I noticed there are no margins in the email templates. So the email looks bad: <img width="1570" height="866" alt="Image" src="https://github.com/user-attachments/assets/4a8bf89d-07e9-4d52-a510-8865d1f59760" /> The solution may be background removal (so let's make it white) or top and bottom margings. ### Expected behavior Top and bottom margins. ### Actual Behavior No top and bottom margins so the content box looks bad. ### Version and Environment v1.5.0 ### Log Output _No response_
Author
Owner

@kmendell commented on GitHub:

Some email clients dont support the html templates, i think thunderbird was on from a older issue, so it falls back to text based templates.

The margin is defined in the html template though

Image
@kmendell commented on GitHub: Some email clients dont support the html templates, i think thunderbird was on from a older issue, so it falls back to text based templates. The margin is defined in the html template though <img width="453" height="885" alt="Image" src="https://github.com/user-attachments/assets/a190237c-a566-4719-b18e-d8d0f20676e8" />
Author
Owner

@kmendell commented on GitHub:

I can make the change and have you test it, ill try to work on it today.

@kmendell commented on GitHub: I can make the change and have you test it, ill try to work on it today.
Author
Owner

@ilyakonovalenko commented on GitHub:

I think the problem comes from CSS styles are not defined for each HTML element via style. Many email clients do not process CSS in <style> tag correctly or ignore some instructions. Any CSS styling should be added to each HTML tag.

So like:

<body>
    <div style="width: 100%; max-width: 600px; margin: 40px auto; background-color: #fff; border-radius: 10px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); padding: 32px;" class="container">
@ilyakonovalenko commented on GitHub: I think the problem comes from CSS styles are not defined for each HTML element via style. Many email clients do not process CSS in <style> tag correctly or ignore some instructions. Any CSS styling should be added to each HTML tag. So like: ``` <body> <div style="width: 100%; max-width: 600px; margin: 40px auto; background-color: #fff; border-radius: 10px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); padding: 32px;" class="container"> ```
Author
Owner

@ilyakonovalenko commented on GitHub:

What email client are you using? It looks fine for me in the Apple Mail app.

The screenshot is from RoundCube web mail client. Other email clients I have do not display any styling for the email at all. So something is definately wrong.

@ilyakonovalenko commented on GitHub: > What email client are you using? It looks fine for me in the Apple Mail app. The screenshot is from RoundCube web mail client. Other email clients I have do not display any styling for the email at all. So something is definately wrong.
Author
Owner

@kmendell commented on GitHub:

What email client are you using? It looks fine for me in the Apple Mail app.

This most likley a email client issue that can render the html/css properly if i had to guess. Just a theory though.

Image
@kmendell commented on GitHub: What email client are you using? It looks fine for me in the Apple Mail app. This most likley a email client issue that can render the html/css properly if i had to guess. Just a theory though. <img width="692" height="472" alt="Image" src="https://github.com/user-attachments/assets/96533aaf-d084-42ed-9035-279b351481a7" />
Author
Owner

@kmendell commented on GitHub:

@ilyakonovalenko Can you try the ghcr.io/pocket-id/pocket-id:email-templates-margins image?

@kmendell commented on GitHub: @ilyakonovalenko Can you try the `ghcr.io/pocket-id/pocket-id:email-templates-margins` image?
Author
Owner

@kmendell commented on GitHub:

@ilyakonovalenko After talking with Elias we are going to try a nre approach for email templates maybe, Will keep you updated.

@kmendell commented on GitHub: @ilyakonovalenko After talking with Elias we are going to try a nre approach for email templates maybe, Will keep you updated.
Author
Owner

@kmendell commented on GitHub:

@ilyakonovalenko Can you try this same image again please? ghcr.io/pocket-id/pocket-id:email-templates-margins

@kmendell commented on GitHub: @ilyakonovalenko Can you try this same image again please? `ghcr.io/pocket-id/pocket-id:email-templates-margins`
Author
Owner

@ilyakonovalenko commented on GitHub:

Yes. Let's test it. One thing I am on Docker setup. So it could be a bit complicated to change template as they are not stored in local file system. (by the way, nice idea to add an ability to use custom email templates in Docker).

@ilyakonovalenko commented on GitHub: Yes. Let's test it. One thing I am on Docker setup. So it could be a bit complicated to change template as they are not stored in local file system. (by the way, nice idea to add an ability to use custom email templates in Docker).
Author
Owner

@ilyakonovalenko commented on GitHub:

It seems you missed <div class="container"> element which has missed margins. So nothing changed.

@ilyakonovalenko commented on GitHub: It seems you missed `<div class="container">` element which has missed margins. So nothing changed.
Author
Owner

@kmendell commented on GitHub:

This is also the react.email version, so it wont be able to be merged till elias gets back but wanted to see if it works for you at least.

@kmendell commented on GitHub: This is also the react.email version, so it wont be able to be merged till elias gets back but wanted to see if it works for you at least.
Author
Owner

@ilyakonovalenko commented on GitHub:

It looks better now. At least the border and shadow are now displaying in all email clients I have. It is not ideal though.

I just tested a bit and here are my changes based on Pocket ID web interface CSS:

<div class="container" style="width: 100%; max-width: 600px; margin: 40px auto; background-color: #fff; border: 1px solid rgba(0, 0, 0, 0.1); border-radius: 8px; box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1); padding: 32px;">

In this way it looks much better (if shadows really needed):
Image

Another idea is to rewrite templates to tables instead of divs as tables work much better in email clients.

@ilyakonovalenko commented on GitHub: It looks better now. At least the border and shadow are now displaying in all email clients I have. It is not ideal though. I just tested a bit and here are my changes based on Pocket ID web interface CSS: ``` <div class="container" style="width: 100%; max-width: 600px; margin: 40px auto; background-color: #fff; border: 1px solid rgba(0, 0, 0, 0.1); border-radius: 8px; box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1); padding: 32px;"> ``` In this way it looks much better (if shadows really needed): <img width="1482" height="498" alt="Image" src="https://github.com/user-attachments/assets/82821fa4-8e94-42ec-8bbb-3a3bc51692a2" /> Another idea is to rewrite templates to tables instead of divs as tables work much better in email clients.
Author
Owner

@kmendell commented on GitHub:

@ilyakonovalenko Can you try this image: ghcr.io/pocket-id/pocket-id:email-template-margins (note its not the same one as before i remoevd the s from template)

@kmendell commented on GitHub: @ilyakonovalenko Can you try this image: `ghcr.io/pocket-id/pocket-id:email-template-margins` (note its not the same one as before i remoevd the s from template)
Author
Owner

@kmendell commented on GitHub:

Ill try a different approach here in a bit to see if its better.

@kmendell commented on GitHub: Ill try a different approach here in a bit to see if its better.
Author
Owner

@kmendell commented on GitHub:

the idea was to try and use react.email, but ill have to wait to elias gets back before we can do that fully.

@kmendell commented on GitHub: the idea was to try and use react.email, but ill have to wait to elias gets back before we can do that fully.
Author
Owner

@ilyakonovalenko commented on GitHub:

email-template-margins build looks good to me. Thank you!

One small thing to consider - logos in SVG format are not supported by many email clients, so they don't display logo. It would be nice if there is a WEBP or PNG version for emails.

@ilyakonovalenko commented on GitHub: `email-template-margins` build looks good to me. Thank you! One small thing to consider - logos in SVG format are not supported by many email clients, so they don't display logo. It would be nice if there is a WEBP or PNG version for emails.
Author
Owner

@kmendell commented on GitHub:

Potentially, Ill have to look at it. Waiting till Elias gets back to deep dive into this one, as not sure we will stick with react.email or not.

@kmendell commented on GitHub: Potentially, Ill have to look at it. Waiting till Elias gets back to deep dive into this one, as not sure we will stick with react.email or not.
Author
Owner

@kmendell commented on GitHub:

@ilyakonovalenko The logo used is from the Pocket ID Instance it self, there is a fallback if no logo is defined , but it should really never get hit. Either way that fallback is a PNG. Ultimately the logo used is what the admin has defined in pocket id. The instance has to be publicly accessible for it to work though.

@kmendell commented on GitHub: @ilyakonovalenko The logo used is from the Pocket ID Instance it self, there is a fallback if no logo is defined , but it should really never get hit. Either way that fallback is a PNG. Ultimately the logo used is what the admin has defined in pocket id. The instance has to be publicly accessible for it to work though.
Author
Owner

@ElioDiNino commented on GitHub:

The instance has to be publicly accessible for it to work though.

Could there be an option to disable including the logo in emails? My instance is not publicly available (it's behind a VPN) so the emails all look a bit broken, which isn't a great user experience (see below). Alternatively, have an option to override the URL used for the emails (so I could point it at somewhere like Dashboard Icons instead)

Image
@ElioDiNino commented on GitHub: > The instance has to be publicly accessible for it to work though. Could there be an option to disable including the logo in emails? My instance is not publicly available (it's behind a VPN) so the emails all look a bit broken, which isn't a great user experience (see below). Alternatively, have an option to override the URL used for the emails (so I could point it at somewhere like [Dashboard Icons](https://dashboardicons.com/icons/pocket-id) instead) <img width="696" height="226" alt="Image" src="https://github.com/user-attachments/assets/1f208cae-f84b-47f5-9dae-4e987678378c" />
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pocket-id#136