I have tried to use the email sending method for sending a random number as otp to the email addresses- BUT this only works on the devices that installed app dirctly from android studio BUT the devices which installed the generated apk cannot send the emails I used the normal email sending code for sending the otp..(But the email sending only works on the device that installed the app directly from android studio..
Random rand = new Random();
n = rand.nextInt(55320) + 1;
rec = reciep.getText().toString();
ml = rec;
subject = "Your OTP FOR app";
textMessage = "YOUR OTP IS ->" + n;
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
session = Session.getDefaultInstance(props, new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("myemail", "mypassword");
}
});
pdialog = ProgressDialog.show(context, "", "Sending OTP...", true);
RetreiveFeedTask task = new RetreiveFeedTask();
task.execute();
}
}
Go on google and turn on less secure app https://myaccount.google.com/lesssecureapps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With