从表单输入发送电子邮件到地址 [英] Send email to address from form input

查看:208
本文介绍了从表单输入发送电子邮件到地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常标准的联系表单,输入名称,电子邮件地址和电话号码。除了按照标准格式将电子邮件发送到指定的电子邮件地址外,

I have a pretty standard contact form with inputs for name, email address and phone number. As well as sending the email to the specified email address as per a standard form,

$to      = 'diysoakwells@hotmail.com';

我也想使用从输入的电子邮件地址的地址发送给用户形成。我正在考虑使用电子邮件输入中的post变量,如下所示:

I would also like to send the email to the user using the address from the email address input from the form. I was thinking using the post variable from the email input like this would work:

$to      = 'diysoakwells@hotmail.com', $email;

但没有运气。有人可以指出我正确的方向,并且在使用这种方法时有任何安全隐患吗?我最终的目标是向用户提供一个复选框,如果选中的话,将电子邮件的副本发送给自己。

but no luck. Can someone point me in the right directiona and are there any security risks in using this approach? I ultimately aim to provide the user with a checkbox that if checked sends a copy of the email to themselves.

这是一个链接到我的表单

Here is a link to my form

http://www.diysoakwells.com.au/cart。 php

提前谢谢:)

<?php
include_once("wsp_captcha.php");

if(WSP_CheckImageCode() != "OK") {
header('location:/form-rejected.php');
die();
}
$to      = 'diysoakwells@hotmail.com';
$subject = 'Order Inquiry';
$jcitems = " <p><b>ORDER:</b></p><p> " . $_POST['jcitems']."<p/>" . "<p><b>Total:</b> $" . $_POST['jctotal']."</p>";
$time = date ("h:i A"); 
$date = date ("l, F jS, Y");
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= 'From: inquiry@diysoakwells.com' . "\r\n" .
'Reply-To: noreply@diysoakwells.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$name = $_POST['name'];
$phone = $_POST['phone'];
$emaile = $_POST['emaile'];
$textbox = $_POST['textbox'];
$text = "<html><body><p><b>Message:</b>\n$textbox</p><p>This form was submitted on Your Web Site on \n $date at\n $time</p><p><b>Customers Email Address:</b> $emaile</p><p><b>Customers Name:</b> $name </p><p><b>Customers Phone Number:</b> $phone </p></html>    </body>";
$body = $text . $jcitems;
mail($to, $subject, $body, $headers);
Header('Location: ../form-accepted.php');
?>


推荐答案

如果您使用php mail()函数,您可以通过指定其他头文件发送副本:

If you use php mail() function you can send copy by specifying additional headers like that:

$headers = 'Cc: '.$emaile;
mail($to, $subject, $message, $headers);

这篇关于从表单输入发送电子邮件到地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆