Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase sendPasswordResetEmail doesn't send email

I have a problem concerning my application using firebase: If I want to enable the users to reset their password themselves firebase doesn't send an email to their address. If I do it myself from the firebase console it works fine. I'm trying it like this:

   resetPassword(email: string) {
        sendPasswordResetEmail(this.auth, email)
            .then(() => {
                // Password reset email sent!
                // ..
            })
            .catch((error) => {
                const errorCode = error.code;
                const errorMessage = error.message;
                // ..
            });
    }

Has someone some insights for me, why this isn't working? I get my auth like this:

this.firebaseApp = initializeApp(environment.firebaseConfig);
this.auth = getAuth(firebaseApp);

I am using the Firebase Modular SDK (V9.0.0+).

I would be really grateful if someone can help me! Cheers!

like image 967
fisto1995 Avatar asked Jul 21 '26 23:07

fisto1995


1 Answers

Where are you getting environment from? If you are getting it correctly and environment.firebaseConfig is not undefined then this should work.

import { initializeApp } from 'firebase/app';
import { getAuth, sendPasswordResetEmail } from "firebase/auth";

const app = initializeApp(environment.firebaseConfig);
const auth = getAuth();
sendPasswordResetEmail(auth, email)
  .then(() => {
    // Password reset email sent!
  })
  .catch((error) => {
    const errorCode = error.code;
    const errorMessage = error.message;
  });
like image 83
ImDarkk Avatar answered Jul 23 '26 12:07

ImDarkk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!