<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                :-: ![](https://img.kancloud.cn/9c/7e/9c7ed5c11d3e6e30434a2f705c388baa_1384x358.png) 郵件發送流程 步驟如下: **1. 獲取郵箱的一些信息** 由于這里用qq郵箱作為發件人,所以需要獲取qq郵箱的一些信息。 (1)登錄qq郵箱:https://mail.qq.com/ 。 ![](https://img.kancloud.cn/d3/a2/d3a25df44adb33320ea9316f5895b163_1426x365.png) (2)開啟下面的服務和復制授權碼。 ![](https://img.kancloud.cn/62/76/6276f50e86a8000df5fa92c89d759813_1593x426.png) (3)獲取qq郵箱的SMTP服務器地址。 ![](https://img.kancloud.cn/c7/c0/c7c0095361f310d72b623f14824c1be5_1316x218.png) ![](https://img.kancloud.cn/1f/8a/1f8ae1c35a6ea4732a83059cfb858f76_1396x253.png) **2. 創建一個SpringBoot項目** ```xml <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- 郵件任務 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> ``` **3. `application.properties`** ```properties spring.mail.username=xxxx2010@qq.com #填的是授權碼,而不是你的賬號密碼 spring.mail.password=qmmorjfrgtxxdieh spring.mail.host=smtp.qq.com spring.mail.properties.mail.smtp.ssl.enable=true ``` **4. 發送郵件** ```java public class Springboot04TaskApplicationTests { @Autowired JavaMailSenderImpl mailSender; /** * 發送只有文本的簡單郵件 */ @Test public void test01() { SimpleMailMessage message = new SimpleMailMessage(); //郵件設置 message.setSubject("通知-今晚開會-01"); message.setText("今晚7:30開會"); message.setFrom("2149582010@qq.com"); //發件人 message.setTo("erthvb@163.com"); //收件人 mailSender.send(message); } /** * 發送復雜郵件 */ @Test public void test02() throws Exception { //1、創建一個復雜的消息郵件 MimeMessage mimeMessage = mailSender.createMimeMessage(); //需要上傳文件,則第二個參數設置為true,否則為false MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true); //郵件設置 helper.setSubject("通知-今晚開會-02"); //發送html郵件,第二個參數設置true,否則發送的是文本 helper.setText("<b style='color:red'>今天 7:30 開會</b>", true); helper.setFrom("2149582010@qq.com"); //發件人 helper.setTo("erthvb@163.com"); //收件人 //上傳文件 helper.addAttachment("607361838.jpg", new File("E:\\task\\607361838.jpg")); helper.addAttachment("SpringBoot高級.pdf", new File("E:\\task\\SpringBoot高級.pdf")); mailSender.send(mimeMessage); } } ``` **5. 收到的郵件** :-: ![](https://img.kancloud.cn/02/ae/02aef53f67175891e5a17cc3f7c57dee_1444x456.png) 簡單郵件 ![](https://img.kancloud.cn/b1/23/b123b2a9ef98fce977d0dcc87542c4c3_1543x724.png) 復雜郵件
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看