我正在使用此处提到的代码:Sending Email in Android using JavaMail API without using the default/built-in app
这是我的代码。当用户到达特定点时,应自动发送邮件但不会发生。权限很完美。
if (User.TOTAL_POINTS >= 2) {
try {
Mail m = new Mail("rubypawa1@gmail.com", "my password");
String[] toArr = {"suvinay123@gmail.com", "rubypawa1@gmail.com.com"};
m.setTo(toArr);
m.setFrom("rubypawa1@gmail.com");
m.setSubject("This is an email sent using my Mail JavaMail wrapper from an Android device.");
m.setBody("Email body.");
if(m.send()) {
Toast.makeText(MyActivity.this, "Email was sent successfully.", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(MyActivity.this, "Email was not sent.", Toast.LENGTH_LONG).show();
}
} catch(Exception e) {
//Toast.makeText(MailApp.this, "There was a problem sending the email.", Toast.LENGTH_LONG).show();
Log.e("MailApp", "Could not send email", e);
}
}