PHP电子邮件脚本有问题

时间:2014-11-11 00:53:50

标签: php

通过电子邮件发送变量不会被填满。我收到所有的电子邮件,但电子邮件是空的,除了主题,但这是连接。 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>

2 个答案:

答案 0 :(得分:1)

$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);

答案 1 :(得分:0)

谢谢杰森,你得到了很大的帮助。我决定将它改为GET,它现在完美无缺。你得到了很大的帮助。

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

无论如何非常感谢。

相关问题