dynamically insert an HTML code in the file, before mailing

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nd1485
Forum Newbie
Posts: 3
Joined: Tue Aug 22, 2006 3:32 am

dynamically insert an HTML code in the file, before mailing

Post 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]
User avatar
ronverdonk
Forum Commoner
Posts: 34
Joined: Sat Jun 10, 2006 7:06 am
Location: Netherlands

Post by ronverdonk »

Now what is the question or the problem?
nd1485
Forum Newbie
Posts: 3
Joined: Tue Aug 22, 2006 3:32 am

Post 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
User avatar
ronverdonk
Forum Commoner
Posts: 34
Joined: Sat Jun 10, 2006 7:06 am
Location: Netherlands

Post 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);
nd1485
Forum Newbie
Posts: 3
Joined: Tue Aug 22, 2006 3:32 am

thanx

Post by nd1485 »

hllo,

thanx... i think that shd do it :-)
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

User avatar
ronverdonk
Forum Commoner
Posts: 34
Joined: Sat Jun 10, 2006 7:06 am
Location: Netherlands

Post by ronverdonk »

Remember that str_ireplace only works with PHP5!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

there are several PHP4 versions of str_ireplace() available..
Post Reply