Email Template Variables / lodash

System Information
  • Strapi Version: 3.4.5
  • Operating System: Linux
  • Database: Mongo
  • Node Version: 8.10.0
  • NPM Version: 3.5.2
  • Yarn Version:

Hiya, I’m trying to add a lodash variable to the email confirmation template.

This is the URL I’m looking to send through this email.

frontend.com/<%= USER.MAIL %>/<%= CODE %>

USER.MAIL is the same of “to” so it shouldn’t be difficult, but I can’t find it.

Thanks in advance.

What I want to do, would also work in here if I could return the user email.

image

frontend.com/reset-password/<%= user.email %>

To explain a bit more, the frontend will handle the request and send it to Strapi in order to have a compulsory step for the user to update the password straight after the confirmation. My solution is partially working, but Strapi doesn’t return the user email.

  confirmEmail(token){
    return axios.get(`${STRAPI_URL}/auth/email-confirmation?confirmation=${token}`)
  }

Thanks.

Any help here? Please.

The object is USER (uppercase) and key is email (with lowercase)

So the correct syntax is:
http://frontend.com/<%= USER.email %>/<%= CODE %>

1 Like

It works! Thanks mate :smiley:

1 Like

Where can I define other variables, for something like the FRONTEND_URL? So the syntax would be…
<%= FRONTEND_URL %><%= USER.email %>/<%= CODE %>

Thanks for your help!

2 Likes

Hi there, it’s me again with a similar issue but now for v4 (using the email designer plugin). I noticed that the syntax has changed from v3 to v4 and it’s partially working. I just can’t get the custom fields that I added to the user’s collection (firstName and lastName)

{{= USER.username }} (native attr: WORKS)
{{= USER.email }} (native attr: WORKS)
{{= USER.firstName }} (custom attr: NOT WORKING)
{{= USER.lastName }} (custom attr: NOT WORKING)

I’m stuck with this, it does not throw any error.
Thanks in advance :slight_smile:

3 Likes

I had the same question.

  1. How do we inject values into emails?
  2. And how do we create custom emails?

It would be really helpful to know this. Or is it necessary to hack the core / uncouple the core email feature and use a proper email template module in node for example?

how to customize my own user variables?

I have the same question? Why is not that in the documentation?

Hi there :wave:

I just opened an issue on the Strapi’s Github repository. You’ll see a way to use other user schema fields in the users-permissions email template.

1 Like