PHP PHPMailer msgHTML <img href absolute Path

I am not able to find an original PHPMailer documentation and so I try it on this way. My understanding is, that if I use msgHTML the PHPMailer will automatically convert the image to an embedded image in the mail. But I have no idea how I have to include an image as a full adress, for example: C:\\Temp\\Test.jpg!

<img src"C:\\Temp\\Test.jpg> does not work!

How do I have to specify $mail->msgHTML($body, ?????, ????)

Because I don't want to vopy my image inside the wwwroot.

Update For some stupid reason PPHMailer does not allow an empty basedir. I figured it out, after looked into the source code:

                if (
                //Only process relative URLs if a basedir is provided (i.e. no absolute local paths)
                !empty($basedir)

Solution:

So the solution for this problem is, to put all images into the same folder, modify the source code or write your own solution with AddEmbeddedImage. What I have done:

             preg_match_all('~<img.*?src=.([\/.a-z0-9:_-]+).*?>~si',$html,$matches);
              $paths = array();
              foreach ($matches[1] as $img) {
                $img_old = $img;
                if(strpos($img, "https://") == false) {
                 $content_id = md5($img);
                 $html = str_replace($img_old,'cid:'.$content_id,$html);
                 $pos = strrpos($img, '/');
                 $name = substr($img, $pos+1);
                 $mail->AddEmbeddedImage($img, $content_id, $name);
                }
           }
           $mail->msgHTML($html);
           $mail->send();

Answer

Solution:

You can try to convert the image to base64, then put in src.

<p>From wikipedia</p>
  <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4
    //8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />
</div>

See this: https://www.w3docs.com/snippets/html/how-to-display-base64-images-in-html.html

Source