Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NC12 ignores custom mail templates for the activity app #160

Closed
BenS89 opened this issue May 24, 2017 · 10 comments
Closed

NC12 ignores custom mail templates for the activity app #160

BenS89 opened this issue May 24, 2017 · 10 comments

Comments

@BenS89
Copy link

BenS89 commented May 24, 2017

Steps to reproduce:

  • Create a custom mail template for the activity app under /themes/customTheme/apps/activity/templates/email.notification.php
  • configure your custom theme in the nextcloud config
  • Do something and wait for the activity app so send notification mails

Expected behavior:
The notification mail uses the configured template (as it was in NC11)

Actual behaviour:
The configured template gets ignored. The mail includes the default template text.

Enabled apps:
Calendar 1.5.3
Contacts 1.5.3

PHP-Version: 7.1.1
OS: Embedded QNAP-Linux

@nickvergessen
Copy link
Member

Yeah the app was migrated to the new email templating system. Not sure if that allows theming yet.

What would youblike to change? Wording or styling?

@BenS89
Copy link
Author

BenS89 commented May 24, 2017

Wording. I temporarily fixed it with changing the corresponding strings within the.js / .json files

@nickvergessen
Copy link
Member

You should be able to replace language files or parts of them with theming as well

@phatair
Copy link

phatair commented May 28, 2017

Hi,
i would like to change the logo "custom cloud" in the mail notification. How can i do this?
Thanks for your help.

@nickvergessen
Copy link
Member

That's a server side issue, see nextcloud/server#5036

@elpraga
Copy link

elpraga commented Jun 19, 2017

Which files should I edit when I want to modify the default email being sent @nickvergessen ? The default template uses .svg images, which would be fine, if google wasn't blocking all svg in gmail. I would like to change them to .png equivalents, so that users can actually see them.

@nickvergessen
Copy link
Member

That issue is being worked on in nextcloud/server#5075

@elpraga
Copy link

elpraga commented Jun 19, 2017

Thanks!

@ams-tschoening
Copy link

Yeah the app was migrated to the new email templating system. Not sure if that allows theming yet.

Where can I found more info about that new templating system and how it interacts with other apps? Are the only available infos these in the docs? Those don't explain much about integration with other apps, how different templates are distinguished from each other etc. I need to know how e.g. the activity app generates mails and how I can customize those entirely. I can't even find code in the app implementing IEMailTemplate, only very few mentions of similar names like the following:

$template = $this->mailer->createEMailTemplate('activity.Notification', [

But those calls don't explain where templates/classes/... need to be stored to customize things.

@ams-tschoening
Copy link

ams-tschoening commented Mar 5, 2021

I've found how individual templates are distinguished: activity.Notification from the example above is the requested template and while it's not documented pretty well, that name is forwarded as $emailId to implementations of IEMailTemplate:

public function __construct(Defaults $themingDefaults,
				IURLGenerator $urlGenerator,
				IFactory $l10nFactory,
				$emailId,
				array $data) {
	$this->themingDefaults = $themingDefaults;
	$this->urlGenerator = $urlGenerator;
	$this->l10nFactory = $l10nFactory;
	$this->htmlBody .= $this->head;
	$this->emailId = $emailId;
	$this->data = $data;
}

The support portal has a freely accessible example app in which that $emailId is used to distinguish things:

public function addBodyButtonGroup(
	string $textLeft, string $urlLeft,
	string $textRight, string $urlRight,
	string $plainTextLeft = '',
	string $plainTextRight = '') {

	// for the welcome email we omit the left button ("Install client") and only show the button that links to the instance
	if ($this->emailId === 'settings.Welcome') {
		parent::addBodyButton($textLeft, $urlLeft, $plainTextLeft);
		return;
	}
	parent::addBodyButtonGroup($textLeft, $urlLeft, $textRight, $urlRight, $plainTextLeft, $plainTextRight);
}

email_template_example.zip

So in the end, there seems to ALWAYS be ONE implementation of IEMailTemplate set per instance of Nextcloud only, because there's only one global config in config.php to do so. The attached example app seems to set that option automatically when enabling/disabling the app already using classes in lib/Migration.

'mail_template_class' => '\OC\Mail\NameOfYourEmailTemplate'

Though being an instance wide implementation, that is able to distinguish differently requested mails for different purposes by the given $emailId and can dispatch to different additional implementations this way. Of course one needs to know which different purposes exist and stuff like that and I couldn't find any documentation for that yet. I guess the easiest way to find what one might be interested in is by searching the code base for createEMailTemplate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants