| 
...
 | 
...
 | 
@@ -282,6 +282,7 @@ class Body { | 
| 
 | 
 | 
     }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
     /**
 | 
| 
 | 
 | 
      * 这个函数的主要目的 组装哪些以附件发送的图片并且需要显示在页面上的
 | 
| 
 | 
 | 
      * 有些邮件里面的图片是通过附件的形式发来的
 | 
| 
 | 
 | 
      * <img src="cid:xxxx" /> 这种就是附件图片,需要替换的
 | 
| 
 | 
 | 
      * @return array
 | 
| 
...
 | 
...
 | 
@@ -290,25 +291,30 @@ class Body { | 
| 
 | 
 | 
      */
 | 
| 
 | 
 | 
     public function getHtmlAndImg():array {
 | 
| 
 | 
 | 
         $html = $this->getHtml();
 | 
| 
 | 
 | 
         $atta = [];
 | 
| 
 | 
 | 
         foreach ($this->items as $item){
 | 
| 
 | 
 | 
             if($item->eq('Content-Disposition','inline')){
 | 
| 
 | 
 | 
                 $atta = $item;
 | 
| 
 | 
 | 
             }
 | 
| 
 | 
 | 
         $attachment = $this->getAttachment(true);
 | 
| 
 | 
 | 
         foreach ($attachment as $item){
 | 
| 
 | 
 | 
             // 替换图片路径
 | 
| 
 | 
 | 
             $html = preg_replace(
 | 
| 
 | 
 | 
                 "/['|\"]cid:".$item->getContentId()."['|\"]/i",
 | 
| 
 | 
 | 
                 '"data:'.$item->getFileType().';base64,'.base64_encode($item->getContent()).'"',
 | 
| 
 | 
 | 
                 $html
 | 
| 
 | 
 | 
             );
 | 
| 
 | 
 | 
         }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         return $html;
 | 
| 
 | 
 | 
     }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
     /**
 | 
| 
 | 
 | 
      * 读取附件
 | 
| 
 | 
 | 
      * @param bool $inline 是否是读取嵌入html中的图片或者其他,一半情况 图片路径以 cid:xxx
 | 
| 
 | 
 | 
      * @return Attachment[]
 | 
| 
 | 
 | 
      * @author:dc
 | 
| 
 | 
 | 
      * @time 2024/9/21 10:05
 | 
| 
 | 
 | 
      * @time 2024/9/23 10:23
 | 
| 
 | 
 | 
      */
 | 
| 
 | 
 | 
     public function getAttachment():array {
 | 
| 
 | 
 | 
     public function getAttachment(bool $inline = false):array {
 | 
| 
 | 
 | 
         $attachment = [];
 | 
| 
 | 
 | 
         foreach ($this->items as $item){
 | 
| 
 | 
 | 
             if($item->eq('Content-Disposition','attachment')){
 | 
| 
 | 
 | 
             if($item->eq('Content-Disposition',$inline ? 'inline' : 'attachment')){
 | 
| 
 | 
 | 
                 $attachment[] = new Attachment($item);
 | 
| 
 | 
 | 
             }
 | 
| 
 | 
 | 
         }
 | 
...
 | 
...
 | 
 |