Page 1 of 1

dynamically insert an HTML code in the file, before mailing

Posted: Tue Aug 22, 2006 3:36 am
by nd1485
JayBird | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


In a certain email program, we are sending the mail as an html file. The file was uploaded earlier. We want an additional html line to be entered into the code, before the mail function is executed.

this is the code:

Code: Select all

$Htmlfile="Upload/Html/".$a;
$fp=fopen($Htmlfile,"r");
$HtmlCode=fread($fp,filesize($Htmlfile));
fclose($fp);
$MessMast .= $HtmlCode;
$MessMast .= chr(13) ;
Now this $MessMast has the html code, and at a later stage of the script, just before we send it, I need to insert some parameters


JayBird | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Tue Aug 22, 2006 4:17 am
by ronverdonk
Now what is the question or the problem?

Posted: Tue Aug 22, 2006 4:21 am
by nd1485
>Now this $MessMast has the html code, and at a later stage of the script, just before >we send it, I need to insert some parameters

The html file can be any file the user would mail. At a later stage in the script, I need to open and insert an HTML into the $MessMast. How do I do this, and be sure that whatever I add goes in before the </HTML>

Thank you for your reply

Posted: Tue Aug 22, 2006 4:47 am
by ronverdonk
Using str_replace or some other replacement function (think of case sensitivity) will do that:

Code: Select all

$MessMast = str_replace('</html>', $YourText.'</html>', $MessMast);

thanx

Posted: Tue Aug 22, 2006 5:15 am
by nd1485
hllo,

thanx... i think that shd do it :-)

Posted: Tue Aug 22, 2006 5:56 am
by Jenk

Posted: Tue Aug 22, 2006 5:58 am
by ronverdonk
Remember that str_ireplace only works with PHP5!

Posted: Tue Aug 22, 2006 8:31 am
by feyd
there are several PHP4 versions of str_ireplace() available..