Support Topics Documentation Slack YouTube Blog

Use user's name in email template

HI
I’m trying to add the user’s name to the email template by using Smart Text.
I’ve read in the documentation that I need to use {Users.name} if I have a column called ‘name’, which I do.
Unfortunately, it’s not working.
Am I doing something wrong?

Hi @Rossita_Aaronson

Can you please specify what exactly is not working? Is the email not sent or the email is sent but it doesn’t contain the user name?

Best Regards,
Maksym

Hi Maksym.
The email is sent just fine.
But instead of the user’s actual name I get {Users.name}.

Does the user you send an email to, exists at Users table?

Yes of course.
The email template i’m trying to change is for password retrieve

As I understand, you try to add {Users.name} smart-text to the system email template “User requests password recovery”?

Exactly

Smart text works only for custom templates. You cannot add it to the system templates.

If you want to have the flexibility and full control you can create your own custom template and implement custom service for password recovery using Business Logic that will send the templates.

Here are general steps for this:

  1. Create a service with two methods: requestPasswordRecovery and confirmPasswordRecovery.
  2. requestPasswordRecovery method receives a request from the user who wants to reset the password. We generate a secret token for this user and put it in a table and associate it with this user.
  3. Send a custom email to the email address of the user with a link to the second method that contains encoded token. The link redirect call the confirmPasswordRecovery method .
  4. confirmPasswordRecovery method checks if the secret token matches the one in the table for this user and if so, reset/change the password and send an email with the new password or - if he wants - give him a link to the page where he enters his new password.
  5. Remove the token from the table. It is also desirable to have a timer, which will periodically remove the expired tokens, so that they do not hang there permanently.

Best Regards,
Maksym

2 Likes

Got it.
Thank you :slightly_smiling_face: