| 
@@ -282,6 +282,7 @@ class Body { | 
 | 
@@ -282,6 +282,7 @@ class Body { | 
| 
282
 | 
     }
 | 
282
 | 
     }
 | 
| 
283
 | 
 
 | 
283
 | 
 
 | 
| 
284
 | 
     /**
 | 
284
 | 
     /**
 | 
| 
 | 
   | 
285
 | 
+     * 这个函数的主要目的 组装哪些以附件发送的图片并且需要显示在页面上的
 | 
| 
285
 | 
      * 有些邮件里面的图片是通过附件的形式发来的
 | 
286
 | 
      * 有些邮件里面的图片是通过附件的形式发来的
 | 
| 
286
 | 
      * <img src="cid:xxxx" /> 这种就是附件图片,需要替换的
 | 
287
 | 
      * <img src="cid:xxxx" /> 这种就是附件图片,需要替换的
 | 
| 
287
 | 
      * @return array
 | 
288
 | 
      * @return array
 | 
 | 
@@ -290,25 +291,30 @@ class Body { | 
 | 
@@ -290,25 +291,30 @@ class Body { | 
| 
290
 | 
      */
 | 
291
 | 
      */
 | 
| 
291
 | 
     public function getHtmlAndImg():array {
 | 
292
 | 
     public function getHtmlAndImg():array {
 | 
| 
292
 | 
         $html = $this->getHtml();
 | 
293
 | 
         $html = $this->getHtml();
 | 
| 
293
 | 
-        $atta = [];
 | 
 | 
   | 
| 
294
 | 
-        foreach ($this->items as $item){
 | 
 | 
   | 
| 
295
 | 
-            if($item->eq('Content-Disposition','inline')){
 | 
 | 
   | 
| 
296
 | 
-                $atta = $item;
 | 
 | 
   | 
| 
297
 | 
-            }
 | 
294
 | 
+        $attachment = $this->getAttachment(true);
 | 
| 
 | 
   | 
295
 | 
+        foreach ($attachment as $item){
 | 
| 
 | 
   | 
296
 | 
+            // 替换图片路径
 | 
| 
 | 
   | 
297
 | 
+            $html = preg_replace(
 | 
| 
 | 
   | 
298
 | 
+                "/['|\"]cid:".$item->getContentId()."['|\"]/i",
 | 
| 
 | 
   | 
299
 | 
+                '"data:'.$item->getFileType().';base64,'.base64_encode($item->getContent()).'"',
 | 
| 
 | 
   | 
300
 | 
+                $html
 | 
| 
 | 
   | 
301
 | 
+            );
 | 
| 
298
 | 
         }
 | 
302
 | 
         }
 | 
| 
299
 | 
 
 | 
303
 | 
 
 | 
| 
 | 
   | 
304
 | 
+        return $html;
 | 
| 
300
 | 
     }
 | 
305
 | 
     }
 | 
| 
301
 | 
 
 | 
306
 | 
 
 | 
| 
302
 | 
     /**
 | 
307
 | 
     /**
 | 
| 
303
 | 
      * 读取附件
 | 
308
 | 
      * 读取附件
 | 
| 
 | 
   | 
309
 | 
+     * @param bool $inline 是否是读取嵌入html中的图片或者其他,一半情况 图片路径以 cid:xxx
 | 
| 
304
 | 
      * @return Attachment[]
 | 
310
 | 
      * @return Attachment[]
 | 
| 
305
 | 
      * @author:dc
 | 
311
 | 
      * @author:dc
 | 
| 
306
 | 
-     * @time 2024/9/21 10:05
 | 
312
 | 
+     * @time 2024/9/23 10:23
 | 
| 
307
 | 
      */
 | 
313
 | 
      */
 | 
| 
308
 | 
-    public function getAttachment():array {
 | 
314
 | 
+    public function getAttachment(bool $inline = false):array {
 | 
| 
309
 | 
         $attachment = [];
 | 
315
 | 
         $attachment = [];
 | 
| 
310
 | 
         foreach ($this->items as $item){
 | 
316
 | 
         foreach ($this->items as $item){
 | 
| 
311
 | 
-            if($item->eq('Content-Disposition','attachment')){
 | 
317
 | 
+            if($item->eq('Content-Disposition',$inline ? 'inline' : 'attachment')){
 | 
| 
312
 | 
                 $attachment[] = new Attachment($item);
 | 
318
 | 
                 $attachment[] = new Attachment($item);
 | 
| 
313
 | 
             }
 | 
319
 | 
             }
 | 
| 
314
 | 
         }
 | 
320
 | 
         }
 |