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.

Close

Regular expression to replace $variable?

student101
2009-06-07
2012-09-18
  • 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="http://www.example.com/uploads/8ball.jpg" 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

      Hi,

      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 http://phpmailer.codeworxtech.com/index.php?pg=methods for more information on PHPmailer methods.