【问题标题】:PHP script for sending email用于发送电子邮件的 PHP 脚本
【发布时间】: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 email


【解决方案1】:

改变你的

 mail( $to, $from, "$subject: $name", $message, $header );

 mail( $to, "$subject: $name", $message, $header );

记得只把from-address放到header中,不要作为附加参数

【讨论】:

  • 抱歉我的回复晚了。谢谢,是的,你是对的,现在一切正常。
猜你喜欢
  • 2011-09-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-12
  • 2011-04-28
  • 2012-08-25
  • 1970-01-01
相关资源
最近更新 更多