所以我在 From: 中显示发件人全名时遇到了麻烦,以电子邮件脚本的形式。
我有这个:
<?php
if(!$_POST) exit;
if (!defined("PHP_EOL")) define("PHP_EOL", "\r\n");
$name = $_POST['name'];
$comments = $_POST['comments'];
if(trim($name) == '') {
echo '<div class="error_message">Attention! You must enter your name.</div>';
exit();
}
$address = "example@example.com, example@example.com";
$e_subject = '' . $name . ' has confirmed their attendance.';
$e_body = "$name blah blah blah blah" . PHP_EOL . PHP_EOL;
$e_content = "\"$comments\"" . PHP_EOL . PHP_EOL;
$e_reply = "Please do not reply to this email";
$msg = wordwrap( $e_body . $e_content . $e_reply, 70 );
$headers = "From: $name" . PHP_EOL;
$headers .= "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-type: text/plain; charset=utf-8" . PHP_EOL;
$headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL;
if(mail($address, $e_subject, $msg, $headers)) {
// Email has sent successfully, echo a success page.
echo "<fieldset>";
echo "<div id='success_page'>";
echo "<h1>Success!</h1>";
echo "<p>Thank you</p>";
echo "</div>";
echo "</fieldset>";
} else {
echo 'ERROR!';
}
如果在名称字段中仅输入一个单词/名称,但只要它们是两个或多个单词,它就会显示(未知发件人)。
我可以将名称分成两个字段,但我真的不想这样做。
我究竟做错了什么?
谢谢!