如何在 PHP 表单中包含提交者的电子邮件?
我正在使用简单的 HTML 表单进行活动注册,并且我想向注册者发送一封 PHP 确认电子邮件,其中包含与发送给管理员的信息相同的信息。
以下是详细信息:
$emailFromName = $_POST['name'];
$emailFrom = $_POST['email'];
$emailFromPhone = $_POST['phone'];
我想使用以下电子邮件地址中 $emailFrom 的值来:
$emailTo = "[email protected]", \"$emailFrom\";
编辑:添加新配置:
$emailHeaders = 'From: "Conference" <[email protected]>' . 'CC: . $emailFrom .';
这显然不起作用,但您明白我的意思我正在努力。
谢谢!
I am using a simple HTML form for an event registration and I would like to send a PHP confirmation email to the registrant with the same information that is going to the administrator.
Here are the details:
$emailFromName = $_POST['name'];
$emailFrom = $_POST['email'];
$emailFromPhone = $_POST['phone'];
I would like to use the value from $emailFrom in the following email address to:
$emailTo = "[email protected]", \"$emailFrom\";
edit: Added new configuration:
$emailHeaders = 'From: "Conference" <[email protected]>' . 'CC: . $emailFrom .';
This obviously doesn't work, but you get the idea of what I am trying to.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要向
mail
函数添加标头...例如:
然后
引用:
You will need to add headers to the
mail
function...for example:
and then
References:
您将
"From: $name <$emailFrom>"
放入mail()
函数的附加参数中:http://php.net/manual/en/function.mail.php
You put
"From: $name <$emailFrom>"
in the additional parameters of themail()
function:http://php.net/manual/en/function.mail.php
那么,基本上您想将邮件副本抄送给用户和管理员吗?
这取决于您使用哪个 PHP 库来发送它。如果您使用默认的 PHP mail() 函数,则需要添加其他标头:
So, basically you want to CC a copy of the message to the user as well as the administrator?
It depends on which PHP library you're using to send it. If you're using the default PHP mail() function, you'll need to add additional headers: