我是说你写的是可以的另外可尝试写作:
mail($to,$subject,$message,"From: [email protected]");
mail($to,$subject,$message,"From: [email protected]\n");
mail($to,$subject,$message,"From: [email protected]\r\n");
mail($to,$subject,$message,"From: [email protected]");
mail($to,$subject,$message,"From: [email protected]\n");
mail($to,$subject,$message,"From: [email protected]\r\n");
mail($to,$subject,$message,"From: feng234 <[email protected]>");
注意其中的空格!!给你一个第四个参数的例子吧。
<%php
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";/* additional headers */
$headers .= "To: Mary <[email protected]>, Kelly <[email protected]>\r\n";
$headers .= "From: Birthday Reminder <[email protected]>\r\n";
$headers .= "Cc: [email protected]\r\n";
$headers .= "Bcc: [email protected]\r\n";/* and now mail it */
mail($to, $subject, $message, $headers);
?>
PHP menual 有这样的列子:file_1.php
<?php
mail("[email protected]", "the subject", $message,
"From: webmaster@{$_SERVER['SERVER_NAME']}\r\n"
."Reply-To: webmaster@{$_SERVER['SERVER_NAME']}\r\n"
."X-Mailer: PHP/" . phpversion());
?>
file_2.php
<?
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";/* additional headers */
$headers .= "From: Birthday Reminder <[email protected]>\r\n";$headers .= "Cc: [email protected]\r\n";
$headers .= "Bcc: [email protected]\r\n";/* and now mail it */
mail($to, $subject, $message, $headers);
?>