0

I am developing an email verification i.e. user enter his/her email, app send a message to user email with some random code. This is kind of OTP system where user has to provide this OTP to verify screen.

My problem is I am not receiving email. I am using below code in the register.java

 private void sendEmail(String mail,String val)
{
    Log.d("mail:",mail);
    Log.d("val",val);
    Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("message/rfc822");
    i.putExtra(Intent.EXTRA_EMAIL  , new String[]{mail});
    i.putExtra(Intent.EXTRA_SUBJECT, "Welcome user");
    i.putExtra(Intent.EXTRA_TEXT   , "Please enter the code "+val+" to verify your account");
    try {
        startActivity(Intent.createChooser(i, "Send mail..."));
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(Register.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
    }



}

I checked the mail and val value in Log.d is showing valid values, but I am not receiving email on my gmail.(i am using my own id for testing). Thanks Deepak

Deepak nigam
  • 99
  • 1
  • 15

1 Answers1

0

As @Mehrdad said you should use a server.

But if you still want to send email from your app follow this answer

The problem with this way is that you need to put your email and password in your app.

Community
  • 1
  • 1
Simon Dzn
  • 150
  • 1
  • 1
  • 8