2 回答
![?](http://img1.sycdn.imooc.com/5458464a00013eb602200220-100-100.jpg)
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.username=test@yandex.ru
spring.mail.password=test122223
![?](http://img1.sycdn.imooc.com/54584cb50001e5b302200220-100-100.jpg)
TA贡献1851条经验 获得超5个赞
试试这个代码:
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();
}
添加回答
举报