如何在 PHP 表单中包含提交者的电子邮件?

发布于 2024-09-24 03:57:47 字数 764 浏览 4 评论 0原文

我正在使用简单的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ˇ宁静的妩媚 2024-10-01 03:57:47

您需要向 mail 函数添加标头...

例如:

$headers = 'From: Family History Conference <[email protected]>' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'CC: ' . $emailFrom . "\r\n";

然后

mail($to, $subject, $message, $headers);

引用:

You will need to add headers to the mail function...

for example:

$headers = 'From: Family History Conference <[email protected]>' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'CC: ' . $emailFrom . "\r\n";

and then

mail($to, $subject, $message, $headers);

References:

抱猫软卧 2024-10-01 03:57:47

您将 "From: $name <$emailFrom>" 放入 mail() 函数的附加参数中:

http://php.net/manual/en/function.mail.php

You put "From: $name <$emailFrom>" in the additional parameters of the mail() function:

http://php.net/manual/en/function.mail.php

梦幻的味道 2024-10-01 03:57:47

那么,基本上您想将邮件副本抄送给用户和管理员吗?

这取决于您使用哪个 PHP 库来发送它。如果您使用默认的 PHP mail() 函数,则需要添加其他标头:

// Additional headers
$headers .= 'Cc: ' . $emailFrom . "\r\n";

// Mail it
mail('[email protected]', $subject, $message, $headers);

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:

// Additional headers
$headers .= 'Cc: ' . $emailFrom . "\r\n";

// Mail it
mail('[email protected]', $subject, $message, $headers);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文