str_replace不替换邮件发送上的字符串

时间:2013-02-02 22:32:33

标签: php str-replace

我正在尝试使用str_replace()在发送电子邮件时插入用户名。它不起作用,我错过了什么吗?电子邮件已处理,但<!--{Username}-->未替换为$en['user']变量

        $text_content = file_get_contents('emails/welcome_txt.tpl');
        $html_content = file_get_contents('emails/welcome.tpl');

        $body = "--$mime_boundary\n";
        $body.= "Content-Type: text/plain; charset=\"charset=us-ascii\"\n";
        $body.= "Content-Transfer-Encoding: 7bit\n\n";
        $body.= str_replace("<!--{Username}-->",$en['user'],$text_content);
        $body.= "\n\n";

        $body.= "--$mime_boundary\n";
        $body.= "Content-Type: text/html; charset=\"UTF-8\"\n";
        $body.= "Content-Transfer-Encoding: 7bit\n\n";    
        $body.= str_replace("<!--{Username}-->",$en['user'],$html_content);
        $body.= "\n\n";
        $body.= "--$mime_boundary--\n";

0 个答案:

没有答案