From 72b688186ff15c08293f31da40cb32e20b4c8ae4 Mon Sep 17 00:00:00 2001 From: Patrick Niebeling Date: Mon, 16 Nov 2026 15:08:13 +0100 Subject: [PATCH] Add the logo and the web wordmark colors to e-mails The HTML layout now shows the logo (inline CID attachment, generated with the favicon script) before "Plenar" in the text color and "IO" in the primary color, like the site header. Muted gray and background match the web tokens. Co-Authored-By: Claude Sonnet 5.5 --- docs/frontend.md | 11 +++++++- resources/favicon/generate.php | 10 +++++++- resources/mail/logo.png | Bin 0 -> 1628 bytes src/Mailer/PollMailer.php | 22 ++++++++++++++++ templates/email/html/admin_link.php | 4 +-- templates/email/html/expiry_reminder.php | 4 +-- templates/email/html/recovery.php | 4 +-- templates/layout/email/html/default.php | 21 ++++++++++++--- tests/TestCase/Mailer/PollMailerTest.php | 31 +++++++++++++++++++++++ 9 files changed, 96 insertions(+), 11 deletions(-) create mode 100644 resources/mail/logo.png create mode 100644 tests/TestCase/Mailer/PollMailerTest.php diff --git a/docs/frontend.md b/docs/frontend.md index e8eea6b..76a9b46 100644 --- a/docs/frontend.md +++ b/docs/frontend.md @@ -44,5 +44,14 @@ Neue Farben als Token in beiden Dark-Blöcken von `plenario.css` pflegen; auf de Das Logo (`.brand__mark` in `plenario.css`) ist auch das Favicon: `webroot/favicon.svg` (moderne Browser), `favicon.ico` (16/32/48 px, Fallback) und `apple-touch-icon.png` (180 px, iOS, deckend ohne Rundung, die macht iOS selbst). Eingebunden über `templates/element/favicon.php` in allen drei Layouts (default, present, error). Die Dateien sind statisch und werden aus -einer Geometrie erzeugt: Ändert sich das Logo, `php resources/favicon/generate.php webroot` ausführen (braucht `ext-gd`) +einer Geometrie erzeugt (auch das Mail-Logo, siehe unten): Ändert sich das Logo, `php resources/favicon/generate.php webroot` ausführen (braucht `ext-gd`) und Farben/Anteile im Skript an `.brand__mark` angleichen. Test: `FaviconTest.php`. + +## E-Mail-Layout + +`templates/layout/email/html/default.php` übernimmt Logo und Farben der Webseite (Light-Theme): Hintergrund `--bg`, Text `--text`, +Grau `--muted`, Buttons/Links und „IO“ in `--primary`. Mails kennen weder Stylesheets noch SVG, deshalb stehen die Werte als +Inline-Styles (Tabelle für die Markenzeile) im Layout und in den Mail-Templates. **Ändert sich ein Token in `plenario.css`, +die Hex-Werte in `templates/layout/email/` und `templates/email/html/` nachziehen.** Das Logo ist `resources/mail/logo.png` +(wird vom Favicon-Generator mit erzeugt) und hängt als Inline-Anhang (`cid:`) an jeder Mail: `PollMailer` fügt es im Konstruktor +hinzu, so erscheint es auch ohne „Bilder laden“ und ohne öffentliche Basis-URL. Test: `PollMailerTest.php`. diff --git a/resources/favicon/generate.php b/resources/favicon/generate.php index a45beb6..a80e7a9 100644 --- a/resources/favicon/generate.php +++ b/resources/favicon/generate.php @@ -1,5 +1,5 @@ $n) { } file_put_contents($out . '/favicon.ico', $ico . implode('', $images)); +// Logo for e-mails (resources/mail/logo.png, attached inline by PollMailer): mail clients show no SVG. +// 96 px, displayed at 32 px for sharp edges on high-DPI screens. +$mailDir = dirname(__DIR__) . '/mail'; +if (!is_dir($mailDir)) { + mkdir($mailDir, 0775, true); +} +file_put_contents($mailDir . '/logo.png', $render(96)); + // iOS ignores transparency (fills black) and rounds the corners itself: opaque full-bleed square. $apple = imagecreatetruecolor(180, 180); $stopsPx = $stops; diff --git a/resources/mail/logo.png b/resources/mail/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..0621606b9368c29b90275f45e07553a9fb58e7b0 GIT binary patch literal 1628 zcmV-i2BZ0jP)<=?3qrRCJ?=%?gP=t4BCY7vg;glUivnAe-~-SEpcz1w{%9M%`6U9I5e2ZT zKRyExUWlj~uQ!)C75x!_000$5MiB_e1`WVGfJv)lNEQn312C*#@s7bE0*nX)2rfj_ za8U@*ulQ-F3oj4>Mj{@X?FeSF_(K4;L@B;t@B!HBXw`CcR=RB z-L?=>cP)3o-c)_Fe$_YAMV>dB^=@dkM1WrW6>xCLOpo9L(7yD$8QBf>bNp5bS8x)T=sRnrdV_rn3^DXFKF@i{O|$ zS~cGV0`69PH@w6es655N@HqmiXU5bWRQmc9KL(Wh*uym{k^Nnu8av=o`k6V_h#pS> zFQn^KCVTP7NI<~&%nRu{{GM(+k(;PY_8|ZOQuWN3id5K^6<;N`@Z-r-e2Di#ehWd< z(0tLraw(rB)_|6ZUaYYjbj{ju7BHl4pkIkSTtkl%z=Zrcm5eW%n3>pNLjDYXPdBzD zFO`l{Ji%ZxbW0!5EHNlpkG9((0#0u(nc z`p(-^{1iDvT`Ylj$|^RFYq68`QU??R4_>~Obje+$eOfARYjVE)ywqIF7 zCE`Q?57fmHm|Z-;gO~aLYg8rT==UrU0anqu8OQA60q(p#HT}D{q}OPZpOXwN^q?JB zKSJlGwQZzJUd2YD7Td`h>Hss^es=M|a`DsXQ$nsd4}>5fQ`_@EjkJ$0MSN-M=oaLS zCo%rV;g#~z3huF2*kH9-OWdXo$b@hEIH$Jffi7hgHPSv2kg4s*BZqlud#eyVswgS} z>4Vmcw&wwnql%&t(774M)N-sKZO;RuMisUb;Eg9S9yvsC^<7c69JfUkwi1xua(vsz zLVVdu#L=rn%7cLZfB9>B9%y2kP*DYUA7Hn(=ORr7iYmBvK(Vwv5A-S#AGltXvvXapDE{rO|5&%@s zjBO#y9LRz7BUj2xtC&0e0xPE<+x;=xLPTvy%h35!(e}Keiks4o-5)b=^Z}Elr0rc2 zRZN}{@ZY!JYabmY!=<9_T@Y2A%_Kf^!cTwQ3zm|$7d)y6UWg*p&}cZ9A}ZIdh;vjC zHqIW-%z_?L$!(7+&eixF0cvPegJHl7fqPUjoH_70>pWqteeiG4G`$O$IQbeIiQ0l= zhlPmxN#+kPi=*3MGNda9Scoci^_n6t0@TpxE|I`3s@TO9)3qZq=0qDb984_hs| a5&r{#>u?L|string|null $profile Mailer profile, see parent + */ + public function __construct(array|string|null $profile = null) + { + parent::__construct($profile); + // Inline attachment: shown without "load images" prompts and independent of a public base URL. + $this->addAttachments([ + 'logo.png' => [ + 'file' => RESOURCES . 'mail' . DS . 'logo.png', + 'mimetype' => 'image/png', + 'contentId' => static::LOGO_CID, + 'contentDisposition' => false, + ], + ]); + } + /** * Sends a mail like send(), but logs transport errors instead of throwing them, * so the user gets a friendly hint and the action itself still succeeds. diff --git a/templates/email/html/admin_link.php b/templates/email/html/admin_link.php index 876d99a..8237dca 100644 --- a/templates/email/html/admin_link.php +++ b/templates/email/html/admin_link.php @@ -11,10 +11,10 @@

-

+

{1}.', '' . h($joinUrl) . '', h($poll->formattedJoinCode())) ?>

expiresAt() !== null) : ?>

expiresAt()->format('d.m.Y'))) ?>

-

+

diff --git a/templates/email/html/expiry_reminder.php b/templates/email/html/expiry_reminder.php index 515d0e8..2c5a271 100644 --- a/templates/email/html/expiry_reminder.php +++ b/templates/email/html/expiry_reminder.php @@ -12,6 +12,6 @@

-

+

-

+

diff --git a/templates/email/html/recovery.php b/templates/email/html/recovery.php index c2c614d..f9aec73 100644 --- a/templates/email/html/recovery.php +++ b/templates/email/html/recovery.php @@ -10,8 +10,8 @@

  • - +
  • -

    +

    diff --git a/templates/layout/email/html/default.php b/templates/layout/email/html/default.php index f885027..bfe92c1 100644 --- a/templates/layout/email/html/default.php +++ b/templates/layout/email/html/default.php @@ -1,17 +1,32 @@ + <?= $this->fetch('title') ?> - -
    -

    PlenarIO

    + +
    + + + + + +
    + + PlenarIO
    fetch('content') ?>
    diff --git a/tests/TestCase/Mailer/PollMailerTest.php b/tests/TestCase/Mailer/PollMailerTest.php new file mode 100644 index 0000000..1d1a46c --- /dev/null +++ b/tests/TestCase/Mailer/PollMailerTest.php @@ -0,0 +1,31 @@ +createPoll('Retro', 'owner@example.org'); + + $this->assertTrue((new PollMailer())->sendSafely('expiryReminder', [$poll, 'https://example.org/admin/x'])); + + $this->assertMailCount(1); + $this->assertMailContainsAttachment('logo.png'); + // The logo is referenced by Content-ID, not by a URL that images-off clients would block. + $this->assertMailContainsHtml('src="cid:' . PollMailer::LOGO_CID . '"'); + // Brand and text colors as on the web (--text, --primary, --muted), not the old off-by-a-bit values. + $this->assertMailContainsHtml('PlenarIO'); + $this->assertMailContainsHtml('color:#5d6280'); + $this->assertMailContainsHtml('background:#f5f6fb'); + } +}