How to include recipient’s name in email template?

Hello,

I have modified the EMailTemplate and would like to include the recipient’s name in the notification message.

For example, if user “A” shares a link with user “B”, user “B” should receive a notification containing the following text:

“B, hello! A shared «123» with you. Click the button below to open it.”

Which variable can I use in the EMailTemplate to insert the recipient’s name?

Thank you!

Hi Slava,

In most Nextcloud email templates, user-specific variables like the recipient’s name can be accessed using placeholders, though the exact variable depends on the notification type and what data is passed to the template.

If you’re modifying a sharing notification template, look for variables like {{recipient.displayName}} or {{sharee.displayName}}. Sometimes it might just be {{displayName}} depending on the context. If those don’t work, you may need to check the corresponding PHP code or log the available variables in the template for debugging.

To include the recipient’s name, you’ll typically want to use the recipientDisplayName variable if it’s available in your template context. Depending on your Nextcloud version or how the notification system is set up, this might already be passed into the template. If not, you may need to dig into the PHP code responsible for building the email context and add it manually.

Also, if you’re customizing emails, don’t forget to consider how things like signature integration can help personalize and professionalize your outgoing messages further.

Thank you for the information!