PHP 表单 - 回复电子邮件的问题
联系表格工作正常,但我不知道如何设置“回复邮件”。 PHP代码如下:
<?php
// Get Data
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$message = strip_tags($_POST['message']);
// Send Message
mail( "Message from $name",
"Name: $name\nEmail: $email\nMessage: $message\n",
"From: $name <[email protected]>" );
?>
我试图做的是替换“[email protected]< /a>" 与 $email 但由于某种原因它崩溃并且从不发送任何内容。
The contact form is working just fine but I can't figure how to setup the "reply mail". The PHP code is as follows:
<?php
// Get Data
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$message = strip_tags($_POST['message']);
// Send Message
mail( "Message from $name",
"Name: $name\nEmail: $email\nMessage: $message\n",
"From: $name <[email protected]>" );
?>
What I tried to do is replace "[email protected]" with $email but for some reason it crashes and never sends anything.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您没有为邮件功能使用正确的参数。看一下 文档
在您的情况下,它将是:
假设您给它一个 $to (表示将电子邮件发送给谁)和一个 $subject (电子邮件的主题)。
You aren't using the correct parameters for the mail function. Take a look at the documentation
In your case, it would be:
Assuming that you gave it a $to (which denotes who to send the email to) and a $subject (the subject of the email).
看这个片段:
在你的代码中,你错过了第一个参数,女巫应该是谁。
Take this snippet:
In your code, you missed the first argument, witch should be to who.
是否只是
回复:[电子邮件受保护]< /code> 您的邮件标头块中缺少标头吗?另外,看起来您缺少
mail()
函数的第一个参数,该参数应该是发送到的地址。将
Reply-to
标头添加到mail()
的第三个参数中。编辑 我错过了问题中的逗号,并认为整个块都是消息,包括姓名和名称。从。上面编辑过。我看到你已经有了一个标题块。
Is it just the
Reply-to: [email protected]
header you're missing in your mail headers block? Also, looks like you're missing the first parameter to themail()
function, which should be the address it's sent to.Add the
Reply-to
header into the third parameter tomail()
.EDIT I missed a comma in the question and thought the whole block was the message, including name & from. Edited above. I see you already had a header block.