2013-02-14 219 views
-1

我需要實現一個忘記密碼的應用程序。需要使用webservice鏈接獲取郵件到用戶標識。Android忘記密碼功能

+1

什麼問題發郵件給用戶? – Renjith 2013-02-14 10:27:45

+0

想要在我的android應用中使用webservices實現忘記密碼功能 – kalyan 2013-02-14 10:32:13

回答

4

您可以使用此tar文件 的activation.jar additionnal.jar 的mail.jar

使用這種方法

 public void send() throws Exception 
{ 
    System.out.println("Send Mail"); 
    try 
    { 
     StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); 
     StrictMode.setThreadPolicy(policy); 

     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 = Session.getDefaultInstance(props,new javax.mail.Authenticator(){protected PasswordAuthentication getPasswordAuthentication(){return new PasswordAuthentication(from,password);}}); 

     Message message = new MimeMessage(session); 
     message.setFrom(new InternetAddress(from)); 
     message.setRecipients(Message.RecipientType.TO, 
     InternetAddress.parse(to)); 
     message.setSubject(subject); 
     String message1 = text; 
     message.setText(message1.toString()); 
     System.out.println("MAIL"); 
     Transport.send(message); 
    } 
    catch(Exception e) 
    { 
     e.printStackTrace(); 
    } 
}