Change style for emails


After I updated my Nextcloud instance to Nextcloud 25, I have problems with the logo in the emails. I have another logo for the header in Nextcloud than on the login screen and this cause a problem. Now when an email is sent from Nextcloud the logo is not looking good, because it takes the background color from the header. Is it possible to change the background for the emails to #ffffff? When I searched I found this in the dokumentation, but because my php skills are very limited, I couldn´t understand how to do it. Email — Nextcloud latest Administration Manual latest documentation

Before Nextcloud 25 it was possible to disable the theming app, but now it seems to be forced to have it enabled and this cause problems. Most of it was possible to solve by enabling the custom css app, but still I can´t change the colors for the search and notification icon.


Could someone please help me with this issue? What I want to do is to have different style for the email than on the webinterface and apps.

With help off chatgpt I tried to create a file in “lib/public/Mail” called “MyClass.php” based on the documentation. The content was the following just as a test:


namespace OCA\MyApp;

use OCP\Mail\EMailTemplate;

class MyClass extends EMailTemplate
   protected $header = <<<EOF
         .logo { display: none !important; }
         .p { font-weight: 700 !important; }

The I added the following to config.php after mail_smtpport:
'mail_template_class' => '\\OCA\\MyApp\\MyClass',

When I then try to send a test email absolutely nothing has changed. What is wrong with this code? On this setup I run Nextcloud 26.0.3.


Now I found a solution, but I guess I have to manually check it after every update, because I’m unsure if the change will be permanent. This post helped me: Customize emails - #3 by Etiennehb

Hi @andreasli:

Are you saying you want a different logo for the header or are you saying when you upgraded NC made the logo different and that is now what is causing problems with the background color?

If you’re willing to post some screenshots, it may make it easier for us to troubleshoot.

My understanding is that by default the email templates inherit settings from the theming settings, but I admittedly haven’t experimented with it much. I do recall some things have been refined recently:

Also, make sure you have the dependencies installed if you want the logos to match up:

The in-depth email customization via custom coding is another path, but requires more work (as you’ve seen). And my impression is it’s supported more as an enterprise feature.

Hopefully we can get the built-in theming integration to work more cleanly with your email needs, but I want to confirm I understand the issue first.


Sorry if I was unclear.

What I want to do is to change the color for the header, but only for the emails. So I want to have the header with background-color #ffffff when sending emails. Otherwise the logo will not look good, because I have two different logos in use. One for the login screen and one for the header inside nextcloud.

I was able to solve it know by using the instruction posted above. Customize emails - #3 by Etiennehb