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 <noreply@anthropic.com>
This commit is contained in:
1 parent
8262411225
commit
72b688186f
9 files changed
+96
-11
No files matched your search
+10
-1
@@ -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`.
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// Generates webroot/favicon.svg, favicon.ico and apple-touch-icon.png (needs ext-gd). Run after a logo change:
|
||||
// Generates webroot/favicon.svg, favicon.ico, apple-touch-icon.png and resources/mail/logo.png (needs ext-gd). Run after a logo change:
|
||||
// php resources/favicon/generate.php webroot
|
||||
// Mirrors .brand__mark in webroot/css/plenario.css:
|
||||
// rounded square (radius 6/22), conic gradient 40/25/20/15 % from 12 o'clock, clockwise.
|
||||
@@ -126,6 +126,14 @@ foreach ($sizes as $i => $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;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
@@ -13,6 +13,28 @@ use Throwable;
|
||||
*/
|
||||
class PollMailer extends Mailer
|
||||
{
|
||||
/**
|
||||
* Content-ID of the logo that layout/email/html/default.php references as `cid:plenario-logo`.
|
||||
*/
|
||||
public const LOGO_CID = 'plenario-logo';
|
||||
|
||||
/**
|
||||
* @param array<string, mixed>|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.
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
<p style="margin:24px 0;">
|
||||
<a href="<?= h($adminUrl) ?>" style="display:inline-block;background:#4b3fe0;color:#ffffff;text-decoration:none;padding:12px 20px;border-radius:8px;font-weight:600;"><?= __('Umfrage verwalten') ?></a>
|
||||
</p>
|
||||
<p style="font-size:13px;color:#5b5f7a;word-break:break-all;"><?= h($adminUrl) ?></p>
|
||||
<p style="font-size:13px;color:#5d6280;word-break:break-all;"><?= h($adminUrl) ?></p>
|
||||
<p><strong><?= __('Wichtig:') ?></strong> <?= __('Wer diesen Link kennt, kann die Umfrage bearbeiten. Gib ihn nicht weiter.') ?></p>
|
||||
<p><?= __('Teilnehmende erreichen die Umfrage unter {0} mit dem Code <strong>{1}</strong>.', '<a href="' . h($joinUrl) . '">' . h($joinUrl) . '</a>', h($poll->formattedJoinCode())) ?></p>
|
||||
<?php if ($poll->expiresAt() !== null) : ?>
|
||||
<p><?= __('Hinweis: Die Umfrage wird am {0} automatisch gelöscht. Vorher erinnern wir dich per E-Mail.', h($poll->expiresAt()->format('d.m.Y'))) ?></p>
|
||||
<?php endif; ?>
|
||||
<p style="font-size:13px;color:#5b5f7a;"><?= __('Du hast diese Umfrage nicht angelegt? Dann kannst du diese E-Mail ignorieren.') ?></p>
|
||||
<p style="font-size:13px;color:#5d6280;"><?= __('Du hast diese Umfrage nicht angelegt? Dann kannst du diese E-Mail ignorieren.') ?></p>
|
||||
@@ -12,6 +12,6 @@
|
||||
<p style="margin:24px 0;">
|
||||
<a href="<?= h($adminUrl) ?>" style="display:inline-block;background:#4b3fe0;color:#ffffff;text-decoration:none;padding:12px 20px;border-radius:8px;font-weight:600;"><?= __('Umfrage öffnen') ?></a>
|
||||
</p>
|
||||
<p style="font-size:13px;color:#5b5f7a;word-break:break-all;"><?= h($adminUrl) ?></p>
|
||||
<p style="font-size:13px;color:#5d6280;word-break:break-all;"><?= h($adminUrl) ?></p>
|
||||
<p><strong><?= __('Wichtig:') ?></strong> <?= __('Wer diesen Link kennt, kann die Umfrage bearbeiten. Gib ihn nicht weiter.') ?></p>
|
||||
<p style="font-size:13px;color:#5b5f7a;"><?= __('Du brauchst die Umfrage nicht mehr? Dann musst du nichts tun.') ?></p>
|
||||
<p style="font-size:13px;color:#5d6280;"><?= __('Du brauchst die Umfrage nicht mehr? Dann musst du nichts tun.') ?></p>
|
||||
@@ -10,8 +10,8 @@
|
||||
<?php foreach ($links as $link) : ?>
|
||||
<li style="margin-bottom:12px;">
|
||||
<a href="<?= h($link['url']) ?>" style="color:#4b3fe0;font-weight:600;"><?= h($link['title']) ?></a><br>
|
||||
<span style="font-size:13px;color:#5b5f7a;"><?= __('angelegt am {0}', h($link['created'])) ?></span>
|
||||
<span style="font-size:13px;color:#5d6280;"><?= __('angelegt am {0}', h($link['created'])) ?></span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<p style="font-size:13px;color:#5b5f7a;"><?= __('Du hast diese E-Mail nicht angefordert? Dann kannst du sie ignorieren – deine Links bleiben unverändert gültig.') ?></p>
|
||||
<p style="font-size:13px;color:#5d6280;"><?= __('Du hast diese E-Mail nicht angefordert? Dann kannst du sie ignorieren – deine Links bleiben unverändert gültig.') ?></p>
|
||||
@@ -1,17 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* HTML mail layout. Colors mirror the web tokens in webroot/css/plenario.css (light theme):
|
||||
* --bg #f5f6fb, --surface #fff, --text #1d1f33, --muted #5d6280, --primary #4b3fe0.
|
||||
* Inline styles and a table for the brand row: mail clients ignore stylesheets and flexbox.
|
||||
*
|
||||
* @var \App\View\AppView $this
|
||||
*/
|
||||
|
||||
use App\Mailer\PollMailer;
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="color-scheme" content="light">
|
||||
<title><?= $this->fetch('title') ?></title>
|
||||
</head>
|
||||
<body style="margin:0;padding:24px;background:#f4f5fb;font-family:Segoe UI,Helvetica,Arial,sans-serif;color:#1d1f33;">
|
||||
<div style="max-width:560px;margin:0 auto;background:#ffffff;border-radius:12px;padding:32px;">
|
||||
<p style="margin:0 0 24px;font-size:20px;font-weight:700;color:#4b3fe0;">PlenarIO</p>
|
||||
<body style="margin:0;padding:24px;background:#f5f6fb;font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;color:#1d1f33;">
|
||||
<div style="max-width:560px;margin:0 auto;background:#ffffff;border-radius:12px;padding:32px;color:#1d1f33;">
|
||||
<table role="presentation" cellpadding="0" cellspacing="0" border="0" style="margin:0 0 24px;">
|
||||
<tr>
|
||||
<td style="padding:0 10px 0 0;vertical-align:middle;">
|
||||
<img src="cid:<?= PollMailer::LOGO_CID ?>" width="32" height="32" alt="" style="display:block;border:0;border-radius:8px;">
|
||||
</td>
|
||||
<td style="vertical-align:middle;font-size:20px;font-weight:800;line-height:1;color:#1d1f33;">Plenar<span style="color:#4b3fe0;">IO</span></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?= $this->fetch('content') ?>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Test\TestCase\Mailer;
|
||||
|
||||
use App\Mailer\PollMailer;
|
||||
use App\Test\TestCase\PlenarioTestTrait;
|
||||
use Cake\TestSuite\EmailTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
|
||||
class PollMailerTest extends TestCase
|
||||
{
|
||||
use EmailTrait;
|
||||
use PlenarioTestTrait;
|
||||
|
||||
public function testHtmlMailShowsLogoAndWebColors(): void
|
||||
{
|
||||
[$poll] = $this->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('Plenar<span style="color:#4b3fe0;">IO</span>');
|
||||
$this->assertMailContainsHtml('color:#5d6280');
|
||||
$this->assertMailContainsHtml('background:#f5f6fb');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user