Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP电子邮件脚本遇到问题_Php - Fatal编程技术网

PHP电子邮件脚本遇到问题

PHP电子邮件脚本遇到问题,php,Php,通过电子邮件发送fine,变量没有被填充。我收到了所有的电子邮件,但电子邮件是空的,除了主题,但这是连接。PHP代码: <html> <body> Thank you! <?php echo($_POST["name"]); ?><br> <a href="http://sagethesite.comuv.com">Back</a> <?php // get var $body = $_POST["comment"

通过电子邮件发送fine,变量没有被填充。我收到了所有的电子邮件,但电子邮件是空的,除了主题,但这是连接。PHP代码:

<html>
<body>

Thank you! <?php echo($_POST["name"]); ?><br>
<a href="http://sagethesite.comuv.com">Back</a>

<?php
// get var
$body = $_POST["comment"];
$name = $_POST["name"];
$email = $_POST["email"];
$subject = "Name: " . $name . " Email: " . $email;

// use wordwrap() if lines are longer than 70 characters
$body = wordwrap($body,70);

//Convert to plain text
$body = strip_tags($body);

// send email
mail("sage@sagethesite.comuv.com" ,$subject , $body);
?>
</body>
</html>

谢谢大家!
表格编号:

<form action="emailhandle.php" method="post" enctype="text/plain">
    Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="text" name="name" placeholder="your name"><br>
    E-mail:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="text" name="email" placeholder="your email"><br>
    Comment:
    <input type="text" name="comment" placeholder="your comment" size="50"><br><br>
    <input type="submit" value="Send">
</form> <a href="#top">Back to top</a>

姓名:

电邮:
评论:

$subject=“新评论”;
//信息
$body=$_POST[“comment”];
//如果行长度超过70个字符,请使用wordwrap()
$body=wordwrap($body,70);
//转换为纯文本
$body=带标签($body);
//发送电子邮件
$name=$_POST[“name”]//假设字段名为“name”
$to=$name.“;
邮件($收件人,$主题,$正文);

谢谢你,杰森,你帮了我大忙。我决定改变它,让它现在可以完美地工作。你帮了大忙

我仍然不知道为什么这个帖子不起作用。但我关心的唯一原因是了解它,它看起来会更好


无论如何,非常感谢。

它怎么不起作用?假设是这样的话,从localhost发送邮件需要一些调整。您在这段代码中有许多错误。这不是从localhost发送的。href属性是网站。您遇到了什么错误?您确定电子邮件地址正确吗?您的电子邮件地址无效,您还应该将邮件转换为纯文本,因为您没有包含任何邮件标题。你还应该定义一个主题。看看我重新编写的代码,看看你是否能通过。谢谢,我现在收到了电子邮件。它们是空的,但没有文本或任何东西。$comment是如何填充的?是的,我只是在研究它。我没有修改我的代码来填充这个body变量,假设字段名是comment,它是POST
$subject = "New comment";

// the message

$body = $_POST["comment"];

// use wordwrap() if lines are longer than 70 characters

$body = wordwrap($body,70);


//Convert to plain text

$body = strip_tags($body);

// send email

$name = $_POST["name"]; //assuming the field is entitled "name"

$to = $name." <sage@sagethewebsite.com>";

mail($to ,$subject, $body);