2013-11-20 77 views
0
 public void successSending() 
    { 
     String server = "smtp.gmail.com"; 
     String port = "465"; 
     String to = "[email protected]"; 
     String from = "[email protected]"; 
     Properties properties = System.getProperties(); 
     properties.put("mail.smtp.auth", "false"); 
     properties.put("mail.smtp.starttls.enable", "true"); 
     properties.put("mail.transport.protocol", "smtp"); 
     properties.put("mail.smtp.host", server); 
     properties.put("mail.smtp.port", port);   
     Session session = Session.getDefaultInstance(properties); 

     } 

在這裏我沒有發送email.please幫助解決這個問題。發送電子郵件沒有在android中的身份驗證

+0

向消息的主題和正文發送消息,同時發送消息Transport.send(message); – patrioit

回答

0

試試這個:

private void sendEmail() { 
    // Setup the recipient in a String array 
    String[] mailto = { "[email protected]" }; 

    // Create a new Intent to send messages 
    Intent sendIntent = new Intent(Intent.ACTION_SEND); 

    // Add attributes to the intent 
    sendIntent.putExtra(Intent.EXTRA_EMAIL, mailto); 
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, "test"); 

    sendIntent.setType("message/rfc822"); 
    startActivity(sendIntent); 

} 

希望這有助於。

+0

我想在不使用默認應用程序的情況下發送郵件並且不進行身份驗證 – patrioit

+0

您需要一個郵件服務器,它可以讓您無需身份驗證即可發送郵件。 Gmail不會讓你這樣做。大多數服務器不會,否則垃圾郵件發送者會一直使用它們。 –

相關問題