如何发送主题中带有空格的电子邮件?
这就是问题; 如果我尝试发送这样的电子邮件(如下)(主题中没有空格),它将成功发送:
mail("$email",ThanksforSubscribe,$name,"From: [email protected]\n");
...但是如果我在主题中放置空格,它将失败:
mail("$email",Thanks for Subscribe,$name,"From: [email protected]\n");
我收到以下错误:
解析错误:语法错误,第23行的subscribe2.php中出现意外的“ for”(T_FOR)
完整的代码:
<?php
// display form if user has not clicked submit
if (!isset($_POST["submit"])) {
?>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
Name:
<input type="text" name="name"><br>
Email: <input type="text"" name="email"></textarea><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
} else { // the user has submitted the form
// Check if the "from" input field is filled out
if (isset($_POST["email"])) {
$email = $_POST["email"]; // sender
$name = $_POST["name"];
// message lines should not exceed 70 characters (PHP rule), so wrap it
$name = wordwrap($name, 70);
// send mail
mail("[email protected]",subscribe,$name,"From: $email\n");
mail("$email",ThanksforSubscribe,$name,"From: [email protected]\n");
echo "Thank you ";
}
}
?>
mail($email,"Thanks for Subscribe",$name,"From: [email protected]\n");
将其放入“”或“”。这样,PHP知道这是一个字符串。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句