2 回答

TA貢獻(xiàn)2051條經(jīng)驗(yàn) 獲得超10個(gè)贊
嘗試添加
spring.mail.properties.mail.smtp.ssl.enable=true
或者
props.put("mail.smtp.ssl.enable", "true");
我不明白你為什么要使用配置類(lèi),如果你使用的是 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.username=test@yandex.ru
spring.mail.password=test122223

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超5個(gè)贊
試試這個(gè)代碼:
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"recipient@example.com"});
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();
}
添加回答
舉報(bào)