我的表格:
<form class="form" role="form"action="message.php" method="POST">
<input type="text" name="name" id="name">
<input type="text" name="message" id="name">
<input type="hidden" name="subject" id="subject" value="New Message" />
<input type="hidden" name="action" value="submit" />
<input type="submit" value="Senden" class="btn" />
</form>
message.php
<?php
$recipient = "my_email@test.com";
$fmtMail= implode("", file("assets/email.htt"));
foreach($_POST as $key=> $val) {
$fmtResponse= str_replace("<$key>", $val, $fmtResponse);
$fmtMail= str_replace("<$key>", $val, $fmtMail);
$from = "FROM: Example <noreply@example.com>\r\n";
}
mail($recipient, $_POST["subject"], $fmtMail, $from);
我的电子邮件表单运行良好,唯一的问题是:当有人填写表单时,我会收到一封不是UTF-8的电子邮件。所以我很难读懂它。我知道我必须写一个地方"Content-Type: text/html; charset=UTF-8"
,但我不知道,我需要把它放在我的代码中的哪个地方。