Regular expression to replace $variable?

  • student101

    student101 - 2009-06-07

    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

      EdTheHead - 2009-06-07


      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.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks