Richard,
        The problem is with the str_replace()s. Consider the following:

<?php
$myvar = 'this is a var.';
$mytext = str_replace('is', 'is not', $myvar);
?>

At this point $myvar still equals 'this is a var.' but $mytext is 'this is
not a var.' $myvar hasn't been modfified by the str_replace so any
additional str_replace()s after it will not have a cumlative effect.

<?php
$mail_content = $mail_template;

$mail_content = str_replace('##fullname##',$fullname,$mail_content);
$mail_content = str_replace('##email##',$email,$mail_content);
$mail_content = str_replace('##domain##',$domainname,$mail_content);
?>

Something like the above would have the effect you're looking for.

--
Rich Cavanaugh
CTO, EnSpot.com

-----Original Message-----
From: Richard Kurth [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 20, 2001 4:32 AM
To: [EMAIL PROTECTED]
Subject: [PHP] email templates and str_replace


  I am trying to set up a template for an email program below you will
  see the test program the $mail_template is pulled from a database
  that is pre saved when it is saved the Placeholders are filled in
  using str_replace. that is what I want it to do. But it does not work.
What am
  I missing hear.

$mail_template= "<html>
<head>
        <title>Web Hosting At ##hostdomain## </title>
</head>

<body bgcolor='#C4C9DB'>
<font size='4' color='#008080'><strong>Dear ##fullname## </strong></font>
<br><br>
<font size='4' color='#008080'><strong>Your webhosting account has been
created. Please use the following data to log in to ##domain##
</strong></font>
<br>
<font size='4' color='#008080'>
<strong><ul type=square>
        <li>Domain:##domain##   </li>
        <li>IP-Address: ##ip## </li>
        <li>Username: ##username##</li>
        <li>Password: ##password##</li>
        <li>Mysql Database: ##userdatabase##  </li>
        <li>Mysql Username: ##newuser## </li>
        <li>Mysql Password: ##newuserpass## </li>
</ul>  </strong>
</font>

<font size='4' color='#008080'><strong>Thanks for choosing ##hostdomain##
<br> Any Questions e-mail ##sales##@##hostdomain##</strong> </font>

</body>
</html>
";

/* message*/
//$mail_template = $message;

$fullname="Richard Kurth";
 $email="[EMAIL PROTECTED]";
 $hostdomain="northwesthost.com";
 $hostname="www";
 $domain="twohot";
  $tld=".com";
 $baseip="234.444.45.444";
 $username="rkurth";
 $password="boat";
 $userdatabase="twohot";
 $newuser="twohot";
 $newuserpass="twohot";
 $sales="sales";
$domainname=$hostname . "." . $domain . $tld;


$mail_content = str_replace('##fullname##',$fullname,$mail_template);
$mail_content = str_replace('##email##',$email,$mail_template);
$mail_content = str_replace('##domain##',$domainname,$mail_template);
$mail_content = str_replace('##ip##',$baseip,$mail_template);
$mail_content = str_replace('##username##',$username,$mail_template);
$mail_content = str_replace('##password##',$password,$mail_template);
$mail_content =
str_replace('##userdatabase##',$userdatabase,$mail_template);
$mail_content = str_replace('##newuser##',$newuser,$mail_template);
$mail_content = str_replace('##newuserpass##',$newuserpass,$mail_template);
$mail_content = str_replace('##hostdomain##',$hostdomain,$mail_template);
$mail_content = str_replace('##sales##',$sales,$mail_template);
/* and now mail it */
/* recipients */
$recipient = "$fullname <$email>" ;
//header
$headers .="From: Sales Department < [EMAIL PROTECTED] \n>";
$headers .= "reply-To:$from\nX-Mailer: PHP/" .phpversion()." \n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";
//subject
$subject1 = $subject;
//mail($recipient, $subject1, $mail_content, $headers);
//print "$recipient, $subject1, $mail_content, $headers";
echo $mail_content;











Best regards,
 Richard
mailto:[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to