【发布时间】:2018-09-06 14:51:38
【问题描述】:
我正在尝试创建一个简单的 PHP 脚本,它将向我的 gmail 帐户发送电子邮件,该脚本正在运行并发送电子邮件,但所有内容都显示在主题行中:
来自:我
到:me@gmail.com
日期:2018 年 3 月 28 日,星期三,上午 10:20
主题:这是发送的内容:姓名:我
Emailme@gmail.com
消息:测试此表单 1邮寄者: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>;
}
【问题讨论】:
-
我建议您非常仔细地查看 PHP 的
mail($to, $subject, $message, $additional_headers, $additional_parameters)函数的参数 -
抱歉我的回复晚了。仔细查看字符串后,Thx 现在都可以正常工作了...