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 0000000..0621606 Binary files /dev/null and b/resources/mail/logo.png differ diff --git a/src/Mailer/PollMailer.php b/src/Mailer/PollMailer.php index 50b201b..9304290 100644 --- a/src/Mailer/PollMailer.php +++ b/src/Mailer/PollMailer.php @@ -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|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'); + } +}