Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow inserting HTML fragments in email templates #38093

Closed
wants to merge 1 commit into from

Conversation

tcitworld
Copy link
Member

This is a proposal, this PR is here for discussions.

Email templates currently only allow to add text bodies, lists and buttons. It's not possible to add formatting or other elements. Also, text bodies are always centered, which can be hard to read when there a lot of text. This provides a way to inject arbitrary HTML in emails, which can be useful in some cases.

One of these cases I have is nextcloud/announcementcenter#644, which would be achieved otherwise by creating an IMessage from scratch, but that prevents consistency and theming.

Right now the HTML fragment is really just injected in the HTML body, but we could validate (very basically, at a XML level) and sanitize it (using SF's HTML Sanitizer).

Another option is to allow for Markdown fragments directly, and do the rendering here (brings another specific dependency though).

TODO

  • Add tests to tests/lib/Mail/EMailTemplateTest.php
  • Add docs for the new feature

Checklist

Email templates currently only allow to add text bodies, lists and buttons. It's not possible to add formatting or other elements. This provides a way to inject arbitrary HTML in emails, which can be useful in some cases.

Signed-off-by: Thomas Citharel <[email protected]>
@tcitworld tcitworld requested review from a team, ArtificialOwl, nfebe and come-nc and removed request for a team May 5, 2023 10:01
@come-nc
Copy link
Contributor

come-nc commented May 9, 2023

I don’t have anything against it, but it does feel like there should be some basic safety check.

@solracsf solracsf added this to the Nextcloud 28 milestone Nov 21, 2023
@blizzz blizzz mentioned this pull request Nov 22, 2023
5 tasks
@blizzz blizzz modified the milestones: Nextcloud 28, Nextcloud 29 Nov 23, 2023
This was referenced Mar 12, 2024
This was referenced Mar 20, 2024
@skjnldsv skjnldsv mentioned this pull request Mar 28, 2024
81 tasks
@skjnldsv skjnldsv modified the milestones: Nextcloud 29, Nextcloud 30 Mar 28, 2024
This was referenced Jul 30, 2024
This was referenced Aug 5, 2024
@skjnldsv skjnldsv mentioned this pull request Aug 13, 2024
@skjnldsv skjnldsv closed this Aug 14, 2024
@skjnldsv skjnldsv removed this from the Nextcloud 30 milestone Aug 14, 2024
@skjnldsv skjnldsv deleted the email-template-html-fragment branch August 30, 2024 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants