0

I am trying to verify the email by firebase but the problem is that no email is sent to the user. Please Help

this is my code:

    private void userLogin() {
        progressBar.setVisibility(View.VISIBLE);
        mAuth.signInWithEmailAndPassword(emailString, passwordString)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if (task.isSuccessful()) {
                            FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
                            if (user.isEmailVerified()) {
                                progressBar.setVisibility(View.GONE);
                                Intent intent = new Intent(LoginActivity.this, MainActivity.class);
                                startActivity(intent);
                                finish();
                            } else {
                                user.sendEmailVerification();
                                Toast.makeText(LoginActivity.this, "Please verified your email address!", Toast.LENGTH_LONG).show();
                            }
                        } else {
                            progressBar.setVisibility(View.GONE);
                            Toast.makeText(LoginActivity.this, "Failed to login! Please check your credentials.", Toast.LENGTH_LONG).show();
                        }
                    }
                });

    }

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • If you don't get an error message when calling `sendEmailVerification()`, it is quite likely that the email was actually sent but didn't show up where you expected it. Check the spam folder of your mail client, and if it isn't there, check with any network administrators to see if it got caught in their spam filters. – Frank van Puffelen Aug 07 '22 at 20:02
  • I do not believe myself! This is what really happened. I found it in spam messages.. after I exhausted myself in editing the code for nothing. Thank you so much – Mohammad Abu Saada Aug 07 '22 at 23:21
  • Good to hear that was it @Mohammad. I linked an answer with some ways to reduce the chances of the messages being marked as spam. – Frank van Puffelen Aug 08 '22 at 00:39

0 Answers0