我正在尝试创建一个简单的PHP脚本,它会将电子邮件发送到我的Gmail帐户,脚本正在运行并发送电子邮件,但所有内容都显示在主题行中:
来自:我
to:me@gmail.com
日期:2018年3月28日星期三上午10点20分
主题:以下是发送的内容:姓名:我&lt; br&gt; Emailme@gmail.com< br&gt;消息:测试此表单1&lt; br&gt;
mailed-by:my.server.cloud
电子邮件正文中没有任何内容!我肯定做错了,所以这是我的代码:
if (isset($_REQUEST['email']))
{
//send email
$to = "me@gmail.com";
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$from = $_REQUEST['email'] ;
$subject = "Email request from " ;
$message = $_REQUEST['message'] ;
$header = "From: $from";
mail( $to, $from, "$subject: $name", $message, $header );
echo "Thank you $name for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<p>Your message was not sent, please click the back button on your
browser and correct the mistakes</p>;
}
答案 0 :(得分:0)
更改您的
mail( $to, $from, "$subject: $name", $message, $header );
到
mail( $to, "$subject: $name", $message, $header );
请记住只将起始地址放入标题中,而不是作为附加参数