Forum Moderators: coopster
I'm going round in circles looking for a half decent solution, I was wondering if anyone out here could lend me a hand.
Depending on several data selections from a user submitted html form, I would like to send off an automatic email reply.
Their are approximately 20 different replies and I would like to be able to customize the response e.g.
"Dear $member,
Your dossier $reference has been acepted...."
For easy edits, I would like to store the template replies in seperate files. Using a Switch statement for the different cases, I would assign content to a "$content" variable which I would then use as below:
<?
$to = $member_email ;
$subject = "$topic" ;
$msg = $content ;
mail($to, $subject, $msg) ;
?>
I have tried "includes" and "requires" and even reading text files using:
$fp = fopen($filename, "r");
$contents = fread($fp, filesize($filename));
fclose($fp);
But I just can't get this to work, the variables in the templates never appear correctly.
Any ideas?
thanks.
I suggest marking the editable sections like so:
[u]email_template.txt[/u]
Dear ##MEMBER##,Your dossier ##REFERENCE## has been acepted....
Then, set up your replacement arrays:
$find = array('##MEMBER##', '##REFERENCE##');
$replace = array($member, $reference);
// Now get the template into a string
$message = implode('', file('/path/email_template.txt'));
// Now do the replacements
$message = str_replace($find, $replace, $message);
// Now $message should be ready to send!
Regards,
Birdman