2012-09-13 37 views
2

我已經創建了登錄demo.I是使用與PHP代碼連接的JSON解析器解析用戶名和密碼。我也爲忘記密碼做了代碼。但是我無法獲取任何郵件。爲什麼?我在該文本框中創建了一個忘記密碼活動,用於輸入電子郵件ID,當我點擊提交按鈕時,郵件應該隨密碼一起發送到我的收件箱。如何操作?任何人都請幫助我?我想在Android中發送忘記密碼的郵件

這是我忘記口令代碼:

package com.Login; 

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.Button; 
import android.widget.EditText; 
import android.widget.TextView; 


public class ForgotPassActivity extends Activity { 
    EditText address, subject, emailbody, et_email; 
    @Override 
protected void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 

    super.onCreate(savedInstanceState); 
    setContentView(R.layout.forgot_password); 
    TextView textv = (TextView) findViewById(R.id.lbl_loginhere); 
    et_email = (EditText) findViewById(R.id.et_email); 
    textv.setOnClickListener(new OnClickListener() { 

     public void onClick(View v) { 
      // TODO Auto-generated method stub 
      ForgotPassActivity.this.finish(); 
      Intent intent = new Intent(); 
      intent.setClass(v.getContext(), LoginActivity.class); 
      startActivity(intent); 

    } 
     //Code For Sending mail 

    }); 
    Button b1 = (Button) findViewById(R.id.submitButton); 
    b1.setOnClickListener(new OnClickListener() { 

     public void onClick(View v) { 
      // TODO Auto-generated method stub 
      sendEmail(); 
     } 

    }); 

} 
    public void sendEmail(){ 


      final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
      emailIntent.setType("plain/text"); 
      emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"[email protected].com"}); 
      emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText()); 
      emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailbody.getText()); 
      ForgotPassActivity.this.startActivity(Intent.createChooser(emailIntent, "Send mail...")); 

} 


} 

回答

1
Edited 

如果您使用任何Web服務的更好的方法是通過將用戶電子郵件地址來調用Web服務和數據庫中的搜索和取記錄。對於安全的方式傳遞數據創建郵政服務,並從您的服務,如PHP或任何其他技術發送郵件到收到的電子郵件與它的密碼。

更新

您可以使用此功能從您的服務郵件()看到所有與鏈接的詳細信息,並在這裏是代碼的簡單片斷

<?php 
// The message 
$message = "Line 1\nLine 2\nLine 3"; 

// In case any of our lines are larger than 70 characters, we should use wordwrap() 
$message = wordwrap($message, 70); 

// Send 
mail('[email protected]', 'My Subject', $message); 
?> 

http://www.w3schools.com/php/php_mail.asp

http://php.net/manual/en/function.mail.php

+2

你不應該把密碼發送到web服務...只是用戶名...然後將來自Web服務的電子郵件發送到該用戶的註冊地址。 – Merlin

+0

是的好主意 – Pratik

+0

@Pratik是的,我使用的是web服務。我需要一些代碼如何使用它? – Rash

相關問題