public void successSending()
{
String server = "smtp.gmail.com";
String port = "465";
String to = "xxxx@gmail.com";
String from = "yyyy@gmail.com";
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帮助解决这个问题。
答案 0 :(得分:0)
试试这个:
private void sendEmail() {
// Setup the recipient in a String array
String[] mailto = { "tets@gmail.com" };
// 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);
}
希望这有帮助。