Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


Regular expression to replace $variable?

  • student101

    I am attempting to create an email application that sends inline images with PHPmailer.
    I haven't found a solution to this simple problem...

    I need to replace all the image(s);
    <img alt="8ball.jpg" width="100" height="100"
    src="" alt="8 Ball" />

    With this; Hoping that the CID: can come from the filename without ext.
    <img alt="8 Ball" src="cid:8ball">

    Am I looking at this all wrong?
    Any ideas?

    • EdTheHead


      You can use MsgHTML($message) method, where $message contains your html code. This will automatically include any images that are in your html code with inline images. In your example it might not work because you are using an absolute path to the image.
      If your image source is src="images/8ball.jpg", MsgHTML will work. Otherwise you can set the cid as you did in the second part and call AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64", $type = "application/octet-stream") explicitly.
      Have a look at for more information on PHPmailer methods.