How to change the content of User Confirmation Email

Hei there, :relaxed:
Cant find where to modify the content of the emails send to user for Confirming or reseting password. Is this feature available in free tier or?
Kind regards,
Behzad :slight_smile:

Hi Behzad :wave: Welcome to the forum.

Here’s a quote from the documentation:

You can use a custom confirmation function to define your own confirmation flows, such as the following examples:

  • Send custom confirmation emails from a specific domain with a particular template using an external service.

To customize the content of the confirmation email you’ll need to:

  • Enable the option to “Run a Confirmation Function”
  • Register an account with some service which can send emails (there are more available than would fit in this comment)
  • Implement a function which sends a request to the email service with the parameters needed for the user to complete the confirmation flow.

I hope this helps :+1:

Hi Kræn,
thanks for the answer. So there is no way Mongo DB provides to handel this in the Realm? I mean to modify the email content from Real.

Kind regards, Behzad :slight_smile:

Correct. The subject line and URL is configurable, but the content and template is only configurable by implementing a function as mentioned above. You might be interested in sharing your thoughts on this thread:

Thanks Kræn :pray: :innocent:
Honestly the mongo dbRealm could be improved. I find the realm documentation lacking alot …
Wish you a nice day. :blush:

Nice day to you, too :slight_smile: And thanks for sharing your feedback.
Are there any other areas (perhaps specific sections) that you’ve felt the need for more / better documentation?

:blush: Actually I have chosen Mongodb platform as our main underlying infrastructure form now and and future. But lacking of well described documentation makes the development a slow…Hopefully it will be better.
I have a question I would be thankful if you could tell me where do I set the user profile data for username/password users? I mean when I signup a user they provide their name and last name,… In documentation I found you user the realm register user function…But I cold not find anywhere in docs how to these profile data. I tried the custom data but that doesnot seem to usefull registering the profile data…
Sorry asking this question here. I am having a deadline soon…
Many Thanks :pray: :pray:

I agree, it’s a bit off-topic and perhaps better for another post in the forum.
You’re going to get my best answer none the less (using Realm Web / JS) here as an example, since I don’t know what platform you’re developing for.

where do I set the user profile data for username/password users?

I’d suggest that you use the custom data feature, that you’ve already been looking into. Once you’ve completed the registerUser and app.logIn you can insert a new document in the custom data collection (I’m using “user-profiles” here as an example):

const email = "";
const password = "a-super-secure-password";
const firstName = "John";
const lastName = "Doe";
// Register the user
await app.emailPasswordAuth.registerUser(email, password);
const credentials = Credentials.emailPassword(email, password);
// Authenticate as that user
const user = await app.logIn(credentials);
// Create the user profile
const userProfiles = user.mongoClient("mongodb-atlas").db("my-database").collection("user-profiles");
await userProfiles.insertOne({ _id:, firstName, lastName });

You can also setup a trigger to add a document (with some default data) upon user creation:

Anyways - I hope this works out for you. We’re always happy to get concrete feedback (links, sections in docs, etc.) on stuff we can improve and if you have any further questions, feel free to create a new post in the forum :slight_smile:

1 Like

Thanks a lot for your kind replies. I am working with React / JS :grinning:
I have mistakenly posted this with another account on the forum. Sure I will add your solution to that post.
The approach you described sounds very good, but one challenge is consider user provides FirstName and LastName at signup. By submitting the sign up form registerUser(email, password). At this point user have to confirm and then log in for user to be marked as Authenticated. How can we persist this FirstName and LastName until the user have first login?
Another senario could be user signs up from one browser and l logs in from another browser.
:pray: :pray: :pray:

I also just came up with an idea. How about if for sign in we only ask for email and password. Then when user is loing for first time we can send/push them to Profile page to update their Personal info…This is a bit tricky as well…I am not sure how convinent is thís solution according user experience…

You’re right, since your app requires confirmation you the user has to confirm before you can post to the collection :thinking: Depending on your use-case you might be able to store it in the local storage.

An entirely different approach is to create a function (which requires at least anonymous authentication) or alternatively enable a webhook (which can be called unauthenticated) and when called with the first and last name it will store these values into the collection, in case no profile already exists for that user. But … this feels a bit like a misuse of the features to me, perhaps another person on the forum has a better suggestion?

Yes I agree easily it becomes complicated. yes let see if we get some other ideas :smile: :handshake: :pray:
Sure these are thing Realm Dev Team can fix hopefully :slight_smile:

I think for this use case a function is your best bet. +1 for making this a bit easier out of the box though!

For this solution you’ll need to:

  • configure custom user data
  • define a function that adds a document for unconfirmed users
  • define an auth trigger that updates that document

When a user first loads your app (i.e. on the sign in/sign up screen) you’ll need to log in with an
Anonymous credential so that you can call functions.

  1. The user fills out the Sign Up form and provides the following info: email, password, firstName, lastName

  2. On submit:

    a. Realm sends the user a confirmation email (or runs a confirmation function)

    b. You call a function that creates a document in the custom user data collection for the user with all the provided info except for their password. The document could probably also include a boolean “isConfirmed” field though that’s not strictly necessary.

  3. The user confirms their email address. This fires an auth trigger (on CREATE) that looks up the user’s document by email, adds the user’s ID to whatever field you specified in the custom data config, and sets isConfirmed to true.

  4. The user (still authed as Anonymous) logs in with their now confirmed email & password. I’d suggest passing the email/password credential to User.linkCredentials() on the anonymous user instead of directly logging in - this associates the anonymous user activity with the email/password account. It probably doesn’t make too much difference but it is a bit cleaner, especially if you’d like to add any features that don’t require login.

1 Like

Great :raised_hands:
Thanks Nick & Kræn . Looks very good. I will implement this.
Wish you a good time forward
:pray: :star_struck:

Hi Nick @nlarew ,
hope you are doing well. I have a question regarding step 2 point b.
Currently in the app I am working on by default anonymous is activated before any user logs in by providers.
By submit button I call a function which inserts the user info expect password in custom data collection. My question is how safe is this first insertion which has been it done by an anonymous user? It seems a security hole. if this is an issue how can we make it safe?
Then later when user is confirmed a trigger runs a function which updates the corresponding document with normal user id.
Kind regards,
Behzad Pashaie