我有一个表单。我使用“发布”方法发送并通过电子邮件发送给注册的多个人。然后,电子邮件的$正文基于模板。没有数据库,没有类,简单的形式。是的,我已经读过这些,他们都在那里,我不能把它放在一起,与这种情况有关。从文本文件获取内容并替换关键字PHP
“email_template.txt” 应该是这样的文字:
Hello #firstname# #lastname#. Thank you for registering! Your registered email is #email#
看起来像这样在处理由PHP
Hello **John Doe**. Thank you registering! Your registered email is **[email protected]**.
在我的PHP我有类似:
<?php
//form and validation
$firstname = "John"; // inputed name on the form, let say
$lastname = "Doe"; // inputed last name
$email = "example"; // inputed email
//email message
$body = ... some type of a get_file_content....
mail($_POST['email'], 'Party Invitation', $body, 'From: [email protected]');
?>
其中$ body是通过此PHP表单提交给注册人的电子邮件。
这会不会以某种方式工作.... $身体=的file_get_contents(email_template.txt); $ body = str_replace(“#firstname#”,$ firstname,$ body); $ body = str_replace(“#lastname#”,$ lastname,$ body); $ body = str_replace(“#email#”,$ email,$ body); – mythoslife
没关系,我明白了! – mythoslife
好的,你找到了引号:) – surivitna