- ππ·Croatia portulaca
@liquidcms it's not working for me, I get a WSOD when I try to send an example mimemail and this in the log:
Error: Class "LanguageInterface" not found in mytheme_preprocess_mimemail_message() (line 41 of /var/www/html/name/web/themes/custom/mytheme/mytheme.theme)
β¦ - π¬π§United Kingdom rivimey
@portulaca It sounds like you need a 'use' statement for LanguageInterface in the file that you have added the code from #10 to. I can't recall the exact place but something of the form:
use \Drupal\Core\...\...\LanguageInterface;
Search existing code for examples.
- ππ·Croatia portulaca
@rivimey thank you!
It's
use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Url;
It's working now, although I'm getting a double slash in the CSS link path
https://example.com//themes/custom/β¦
Should the variable be without it?
$variables['mail_css'] = $base_path . 'themes/custom/my_theme/css/mail.css';
- First commit to issue fork.
- πΊπΈUnited States tr Cascadia
@malcomio: Are you planning on working on this issue?
- π¬π§United Kingdom malcomio
In the project where we're using mimemail, we ended up adding a preprocess in our theme, as suggested in #10, and I haven't had a chance to make progress on a contributed version.
- πΊπΈUnited States aytee
We used the preprocess theme suggestion as in #10. This successfully includes the mail.css file.
- π΅π±Poland pawel.traczynski Warsaw
Hi. The method from #10 is adding a link to the mail.css in the mimemail-message template. From what I saw it did not work in all cases. To actually add the CSS into the template, I have used the below code:
/** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */ $theme_handler = \Drupal::service('theme_handler'); $theme_path = $theme_handler->getTheme('YOUR_THEME')->getPath(); $css = FALSE; // Assuming mail.css is in a /css subdirectory where all other css is. $css_path = DRUPAL_ROOT . '/' . $theme_path . '/css/mail.css'; try { $css = file_get_contents($css_path); } catch (Exception $exception) { Drupal::logger('YOUR_THEME')->error(t('Failed to get contentns of mail.css file while using mimemail-message template. Exception message: @exception', [ '@exception' => $exception->getMessage(), ])); } if ($css) { $variables['css'] = $css; }
With this code there is not need to modify the mimemail-message twig template unless you want to add some additional markup in it.
I hope this helps someone.
- π§πΎBelarus dewalt
Looks like "Converts CSS styles into inline style attributes." feature isn't implemented in D8+ too. Please add notes to the module page, because the feature is important for us and it was the main point to try this module. For a now I'll try to attach "twig/cssinliner-extra".
- π¬πGhana tylvis
@pawel.traczynski
Where exactly is the code inserted?
Thanks. - πΊπΈUnited States tr Cascadia
Looks like "Converts CSS styles into inline style attributes." feature isn't implemented in D8+ too. Please add notes to the module page, because the feature is important for us and it was the main point to try this module.
@dewalt: That is off-topic for this issue. For the record, the mimemail_compress sub-module, which was used to inline CSS, was removed in the D7->D8 transition. See #2138947: Drupal 8 version β . There was absolutely no community interest in porting that sub-module to Drupal 8+, see π Port mimemail_compress module to D8 Closed: won't fix . Since this issue is important to you, perhaps you can contribute an implementation?
This current issue is about including a mail.css from the theme into sent emails.