最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

spring boot發(fā)簡(jiǎn)單文本郵件案例

 更新時(shí)間:2019年10月17日 10:10:22   作者:稚語(yǔ)希聽  
這篇文章主要介紹了spring boot發(fā)簡(jiǎn)單文本郵件案例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

首先要去郵箱打開POP3/SMTP權(quán)限:

然后會(huì)提供個(gè)授權(quán)碼,用來(lái)發(fā)送郵件。忘記了,可以點(diǎn)生成授權(quán)碼再次生成。

1、引入spring boot自帶的mail依賴,這里版本用的:<spring-boot.version>1.4.3.RELEASE</spring-boot.version>

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-mail</artifactId>
  <version>${spring-boot.version}</version>
  <scope>provided</scope>
</dependency>

2、spring boot配置文件添加郵箱參數(shù)信息

spring.mail.host=smtp.qq.com
spring.mail.username=你的qq號(hào)碼@qq.com
spring.mail.password=qq郵箱開啟SMTP提供的授權(quán)碼(注意:不是你的qq郵箱密碼)#下面一般不用動(dòng)
spring.mail.default-encoding=${spring.http.encoding.charset}
spring.mail.properties.mail.smtp.connectiontimeout=5000 
spring.mail.properties.mail.smtp.timeout=3000
spring.mail.properties.mail.smtp.writetimeout=5000
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true

3、測(cè)試發(fā)送

@Autowired
        private JavaMailSender mailSender;
        
        @Value("${spring.mail.username}")
        private String from;


SimpleMailMessage smm = new SimpleMailMessage();
            smm.setFrom(from);
            smm.setTo("發(fā)送方郵件地址");
            smm.setSubject("springboot測(cè)試郵件");
            smm.setText("簡(jiǎn)單文本郵件測(cè)試發(fā)送!");
            mailSender.send(smm);

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

镶黄旗| 原阳县| 松江区| 万全县| 富阳市| 抚松县| 高碑店市| 辽阳市| 台南市| 凉城县| 平遥县| 全州县| 邵东县| 四子王旗| 容城县| 神木县| 赫章县| 辽宁省| 汉寿县| 文成县| 富川| 吉木萨尔县| 沙田区| 留坝县| 铜梁县| 赤壁市| 边坝县| 察哈| 武城县| 察雅县| 江达县| 台北市| 留坝县| 海兴县| 广宗县| 石柱| 绥阳县| 安溪县| 平江县| 乾安县| 唐海县|