Symfony mailer - Email template inline CSS

Created on 5 December 2023, 7 months ago

Problem/Motivation

We’re currently hardcoding our CSS in our email.html.twig

https://www.drupal.org/docs/contributed-modules/drupal-symfony-mailer/ge... β†’

The documentation states we’re better of using a library called email in our active theme.
This will be used in

class DefaultsEmailAdjuster extends EmailAdjusterBase {

  /**
   * {@inheritdoc}
   */
  public function build(EmailInterface $email) {
    $theme = $email->getTheme();
    $email->setSender('<site>')
      ->addTextHeader('X-Mailer', 'Drupal')
      ->addLibrary("$theme/email");

    if ($default_transport = MailerTransport::loadDefault()) {
      $email->setTransportDsn($default_transport->getDsn());
    }
  }

}

Proposed resolution

Move the CSS out of the template in to a library.

πŸ› Bug report
Status

Closed: won't fix

Version

2.5

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands ronaldtebrake

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024