【问题标题】:Can't send a password reminder email无法发送密码提醒电子邮件
【发布时间】:2015-08-30 14:04:22
【问题描述】:

我尝试创建某种密码提醒,将密码发送到用户电子邮件。 相反,每当我尝试通过应用程序发送此邮件时,我只能进入发送 SMS 页面。 我正在使用最新的 android studio 版本。

    public void ForgetPasswordEvent (View view) {
        //AlertDialog recovery = new AlertDialog();
        final AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Please enter your registered email");
// Set up the input
        final EditText input = new EditText(this);
// Specify the type of input expected;
        input.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
        builder.setView(input);
// Set up the buttons
        builder.setPositiveButton("Send", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                m_Text= input.getText().toString();
                Log.i("Send email", "");

//              String[] TO = {m_Text.toString()};
                String[] TO = {"erez@manageyourtrip.com"};
                String[] CC = {"erez@manageyourtrip.com"};
                Intent emailIntent = new Intent(Intent.ACTION_SEND);
                emailIntent.setData(Uri.parse("mailto:"));
                emailIntent.setType("text/plain");


                emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
                emailIntent.putExtra(Intent.EXTRA_CC, CC);
                emailIntent.putExtra(Intent.EXTRA_SUBJECT, "MYT GuideApp password recovery");
                emailIntent.putExtra(Intent.EXTRA_TEXT, "Your password is 123456");

                try {
                    startActivity(createChooser(emailIntent, "Send mail..."));
                    finish();
                    Log.i("Finished sending email", "");
                } catch (android.content.ActivityNotFoundException ex) {
                    Toast.makeText(MainActivity.this,
                            "There is no email client installed.", Toast.LENGTH_SHORT).show();
                }

            }
        });
        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });

        builder.show();

【问题讨论】:

  • 您不应该发送密码。您应该重置它并让用户创建一个新的。如果您希望应用程序的安全性,您应该无法获得密码。
  • 在这种特殊情况下,我想发送旧密码(在这种情况下为 1-6)。但这不是问题。如何直接从我的应用发送邮件?

标签: android password-recovery


【解决方案1】:

setType("text/plain") 太“宽”了。

你应该使用类似的东西:

setType("message/rfc822")

免责声明:我仍然不赞成这种功能。我不会使用(或推荐)能够发送我的密码的应用程序。

来源:Another question asking the same thing

【讨论】:

  • 好的,我已经解决了问题.. 未正确配置电子邮件帐户。现在我如何发送自动电子邮件?该应用程序会打开一个新的邮件表单,其中包含我所写的详细信息(收件人邮件、主题和文本)。
猜你喜欢
  • 2018-12-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-27
  • 2014-09-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多