简体   繁体   English

Android应用中的电子邮件验证

[英]Email verification in android app

I am developing an email verification ie 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. 这是一种OTP系统,用户必须提供此OTP来验证屏幕。

My problem is I am not receiving email. 我的问题是我没有收到电子邮件。 I am using below code in the register.java 我在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). 我检查了Log.d中的mail和val值是否显示有效值,但我没有在gmail上收到电子邮件(我使用自己的ID进行测试)。 Thanks Deepak 谢谢Deepak

As @Mehrdad said you should use a server. 正如@Mehrdad所说,您应该使用服务器。

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. 这种方式的问题是,您需要在应用程序中输入电子邮件和密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM