2 回答

TA貢獻2051條經驗 獲得超10個贊
嘗試添加
spring.mail.properties.mail.smtp.ssl.enable=true
或者
props.put("mail.smtp.ssl.enable", "true");
我不明白你為什么要使用配置類,如果你使用的是 spring boot 2,你可以將所有電子郵件配置放在你的 application.properties 文件中:
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.ssl.enable=true
spring.mail.host=smtp.yandex.ru
spring.mail.port=465
spring.mail.password=test122223

TA貢獻1851條經驗 獲得超5個贊
試試這個代碼:
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"[email protected]"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT , "body of email");
try{
startActivity(Intent.createChooser(i, "Send mail..."));
}
catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MyActivity.this, "There are no email clients installed.",
Toast.LENGTH_SHORT).show();
}
添加回答
舉報