45

I'm using firebase auth in my app and i'm setting up password-less email sign up.

I have managed to set the email from my own domain but how do i change the text sent in the email for magic link? I can see the configuration for the other template emails but not this one.

The email in question is this one:

Hello, We received a request to sign in to teamname using this email address. If you want to sign in with your youremail account, click this link: link If you did not request this link, you can safely ignore this email. Thanks, 

4 Answers 4

78

There is no way to edit any of the email templates that Firebase Authentication uses. The reason for this is that this allows bad actors to use Firebase to spam people, which would put the service at risk.

To control what message gets sent, you'll have to send it yourself and handle the verification flow with a custom email action handler. See How to modify Email Confirmation message - Firebase.

You could also take full control of the verification flow, and then use the Admin SDK to set the emailVerified flag of the user's profile.

Sign up to request clarification or add additional context in comments.

9 Comments

Thanks Frank, You can change the message in the other emails like the email verification & password reset, without having to send the email myself so why is it that you cannot change the message for the magic link.
Frank works on the Firebase team. This should be the accepted answer.
Can we please change Sender name? That's the only thing I want to change in the template, and this can't be used for spam in any way 🙏
Lol, file a feature request. I literally just filed this feature request before reading this last comment. 2 years and still waiting it seems. I don't understand why Firebase would implement a sign in with email feature and then puposely break it. Doing so doesn't fix spam it just moves the problem to another service. This shouldn't be the accepted answer. An acceptable answer would tell us how to setup a custom email template for this service, which at present we need to cobble together with cloud functions and a private SMTP server.
Is it possible to at least change the project-xxxx reference? UPDATE: yet it is: "Public-facing name" in project settings
The "Public-facing name" field in Firebase project settings no longer exists (at least not for me). Instead, you need to verify app ownership at console.cloud.google.com/auth/branding and get Google's approval to update your APP_NAME. Without this, Google will send your raw Project ID (not your app name) in authentication emails, which looks suspicious and confuses users. I've submitted a request to Google to add documentation about this on the Firebase auth template page to help others avoid this confusion.
|
9

Following on from Frank's answer, you will have to create your own email action link using the Firebase Admin SDK and then put that link in your custom email which you will then send using whatever service (Sendgrid, Mailgun, etc.).

See how to create the action link here: Generating Email Action Links

Comments

7

There are two ways to customize the email body when using the Firebase authentication service. However, the drawback is that you will have to create a backend to send the email yourself rather than just using a function from the SDK that handles everything automatically.

  1. Generate email action links: This is the most efficient method, it requires that you use the Firebase Admin SDK to generate a link that will be embedded in emails sent to your users. Here is an example code that shows how to create an API to send customized verification emails using Express as the backend:

    // Creating a POST route that sends customized verification emails app.post('/send-custom-verification-email', async (req, res) => { const {userEmail, redirectUrl} = req.body const actionCodeSettings = { url: redirectUrl } try{ // generate action like with the Firebase Admin SDK const actionLink = await getAuth() .generateEmailVerificationLink(userEmail, actionCodeSettings) // embedding action link to customized verification email template const template = await ejs.renderFile('views/verify-email.ejs', { actionLink }) // send verification email using SendGrid, Nodemailer, etc. await sendVerificationEmail(userEmail, template, actionLink) res.status(200).json({message:'Email successfully sent'}) }catch(error){ // handle errors } }) 

    You can read more about it in the article I wrote here

  2. Take full control over the workflow: With this, the Firebase Admin SDK won't be used to generate an action link, but rather, you will generate the link yourself and create an API that uses the Admin SDK to handle the action to be taken whenever the link is clicked.

    To do this you will have to create two API routes. One is a route that sends the emails and the other is a route that uses the Firebase Admin SDK to handle the action to be taken when the link attached to the email is clicked.

1 Comment

Is this a secure way to change email template. I need to know are there any chance to go emails in to spam folder through this method.
3

the only way to customize your email body is to install firebase extension called Trigger Email but it'll put you on the Blaze plan because it makes requests to third-party APIs, and as they specified on the extension's page you'll only be charged for usage that exceeds Firebase's free tier.

1 Comment

I don't believe Trigger Email can be used to change the Email Action Handlers (i.e. Reset Password, Verify Email, etc.). If it can, can you please provide a link to a tutorial showing this functionality?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.