第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

為什么我不能發(fā)送電子郵件?

為什么我不能發(fā)送電子郵件?

手掌心 2023-03-23 13:44:19
我面臨無(wú)法發(fā)送電子郵件的事實(shí)。我不明白原因。我使用 Spting Boot 2。該示例使用 JavaMailSender 類(lèi)。但是你可以不用它的實(shí)現(xiàn)和在 application.properties 中指定的必要參數(shù)嗎?@Configurationpublic class MainConfiguration {    @Bean    public JavaMailSender getJavaMailSender() {        JavaMailSenderImpl mailSender = new JavaMailSenderImpl();        mailSender.setHost("smtp.yandex.ru");        mailSender.setPort(465);        mailSender.setUsername("test@yandex.ru");        mailSender.setPassword("test122223");        Properties props = mailSender.getJavaMailProperties();        props.put("mail.transport.protocol", "smtp");        props.put("mail.smtp.auth", "true");        props.put("mail.smtp.starttls.enable", "true");        props.put("mail.debug", "true");        props.put("mail.smtp.socketFactory.port", "465");        props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");        //props.put("mail.smtp.timeout", 1000);        return mailSender;    }    @Bean    public SimpleMailMessage templateSimpleMessage() {        SimpleMailMessage message = new SimpleMailMessage();        message.setText("This is the test email template for your email:");        return message;    }}2 分鐘后,出現(xiàn)錯(cuò)誤:"javax.mail.MessagingException: Could not connect to SMTP host"
查看完整描述

2 回答

?
侃侃無(wú)極

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


查看完整回答
反對(duì) 回復(fù) 2023-03-23
?
江戶(hù)川亂折騰

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();

   }


查看完整回答
反對(duì) 回復(fù) 2023-03-23
  • 2 回答
  • 0 關(guān)注
  • 120 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)