Home > Net >  Why did this code fail to send password reset link in firebase (Reactjs)?
Why did this code fail to send password reset link in firebase (Reactjs)?

Time:07-10

I am new to firebase and I am trying to handle firebase user authentication in React.js. I did manage to create users with email and passwords. But, now I would like to send the user an Email link to reset their password. My code currently look like this.

// This line of code belongs to the top
import { auth } from '../firebaseConfig'

//This part goes under the React component
    <p onClick={async () => {
      try{
        await sendPasswordResetEmail(auth, // My Email Id)
        alert('Password reset link has been sent to your email')
      }
      catch(err){
        alert(err)
      }
    }}
    >Forgot your Password ?</p>

However, I do not get any error messages and I do get the alert message that says "Password reset link has been sent to your email." Unfortunately, I didn't receive any email. Any help will be appreciated. Note that I have given my own email id as the parameter for testing purposes.

CodePudding user response:

Did you check your spam folder? We recently see a lot of the emails from Firebase Authentication ending up in the user's spam folder.

To reduce the chances of this happening, consider taking more control of the email delivery yourself.

  1. As a first step, consider using a custom domain with your project. Email that comes from a custom domain has less chance of being marked as span.
  2. As a second step, consider setting up your own SMTP server.) for delivering the email, so that the emails are not being delivered from Firebase's shared infrastructure anymore.

While these steps are more involved, they typically will drastically reduce the cases where the messages from Firebase Authentication are marked as spam.

  • Related