Re: [SMARTY] sending emails using my smarty templates

From: Date: Fri, 21 Jan 2005 19:38:58 +0000
Subject: Re: [SMARTY] sending emails using my smarty templates
References: 1 2 3 4 5 6 7 8  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-12193@lists.php.net to get a copy of this message
Abdul-Wahid Paterson wrote:
I had thought of using this.... http://uk.php.net/manual/en/function.dom-domdocument-loadhtml.php Using the new DOM functions you should be able to load the HTML and automatically extract all the <img> tags. The big BUT is... 1. I think it is only available in PHP5
correct.
2. I have not tested it
correct. ;-)
Can anyone with PHP5 installed work out (or does anyone know) if this
why not install PHP5 on your machine?
would in theory work? :)
you can definitely use the PHP5 XML/DOM extension(s) to manipulate an bits of HTML (including doing what you want to do here) - but I bet its quicker/easier with a regexp, a few step you would have to go to: 1. find every occurance of the src attribute in an image tag (in your html) 2. for every 'src' value you find you have to download the file (maybe its on your server already so then you don't!) 3. attach the image to the email (lets assume you use phpmailer) giving a 'cid' identifier (using the filename minus thew extension would be handy). 4. replace every occurance of the src attribute in an image tag with a 'cid' identifier - using backreferences that will be quite easy if you have previously made the 'cid' to equal the filename minus the extension. 5. send functions that would help you greatly here are preg_match_all() and preg_replace(); for downloading the img files you may be able to use file_get_contents(): http://nl2.php.net/manual/en/function.file-get-contents.php
Abdul-Wahid On Fri, 21 Jan 2005 17:41:37 +0000, pete M <pmorgan@ukds.net> wrote:


« previous php.smarty.general (#12193) next »