@@ -34,6 +34,8 @@ class EMailTemplate implements IEMailTemplate {
3434 protected bool $ bodyListOpened = false ;
3535 /** indicated if the footer is added */
3636 protected bool $ footerAdded = false ;
37+ /** @var array<array{name: string, content: string, mimeType: string}> images to embed inline, referenced via cid: */
38+ protected array $ inlineImages = [];
3739
3840 protected string $ head = <<<EOF
3941<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -355,8 +357,25 @@ public function addHeader(): void {
355357 $ logoSizeDimensions = ' width=" ' . $ this ->logoWidth . '" height=" ' . $ this ->logoHeight . '" ' ;
356358 }
357359
358- $ logoUrl = $ this ->urlGenerator ->getAbsoluteURL ($ this ->themingDefaults ->getLogo (false ));
359- $ this ->htmlBody .= vsprintf ($ this ->header , [$ this ->themingDefaults ->getDefaultColorPrimary (), $ logoUrl , $ this ->themingDefaults ->getName (), $ logoSizeDimensions ]);
360+ $ logoImage = $ this ->themingDefaults ->getLogoImage ();
361+ if ($ logoImage !== null ) {
362+ // Embed the logo directly in the message instead of linking to it, so mail
363+ // clients don't have to fetch it from the internet (some (e.g. gmail) block that).
364+ $ logoSrc = 'cid:logo ' ;
365+ $ this ->inlineImages [] = ['name ' => 'logo ' ] + $ logoImage ;
366+ } else {
367+ $ logoSrc = $ this ->urlGenerator ->getAbsoluteURL ($ this ->themingDefaults ->getLogo (false ));
368+ }
369+ $ this ->htmlBody .= vsprintf ($ this ->header , [$ this ->themingDefaults ->getDefaultColorPrimary (), $ logoSrc , $ this ->themingDefaults ->getName (), $ logoSizeDimensions ]);
370+ }
371+
372+ /**
373+ * Images that must be embedded inline in the message, referenced via `cid:<name>` in the HTML body
374+ *
375+ * @return array<array{name: string, content: string, mimeType: string}>
376+ */
377+ public function getInlineImages (): array {
378+ return $ this ->inlineImages ;
360379 }
361380
362381 /**
0 commit comments