如何制作联系表格向用户发送确认电子邮件?

时间:2012-05-03 02:10:02

标签: php

这是我到目前为止所拥有的......

 $full_name = $_REQUEST['full_name'] ;         
 $company = $_REQUEST['company'] ;       
 $abn = $_REQUEST['abn'] ;     
 $customer_number = $_REQUEST['customer_number'] ;     
 $about = $_REQUEST['about'] ;     
 $areacode = $_REQUEST['areacode'] ;     
 $telephone = $_REQUEST['telephone'] ;         
 $email = $_REQUEST['email'] ;     
 $message = $_REQUEST['message'] ;     
 $body =" Full Name: ".$full_name."\n

Company: ".$company."\n                 
ABN: ".$abn."\n    
Customer Number: ".$customer_number."\n
About: ".$about."\n       
Area Code: ".$areacode."\n      
Telephone: ".$telephone."\n     
Email: ".$email."\n                     
Message: ".$message;

$to = "$email";

 mail( "info@rentforbusiness.com.au", "Contact Us Form", $body, "From: $email" );

2 个答案:

答案 0 :(得分:0)

就像你自己做的那样。

mail($email, "Thanks For Resistering", $a_thank_you_message, "From: info@rentforbusiness.com.au" );

答案 1 :(得分:0)

在数据库中创建一个表。它应包含字段:

  • id(自动增量)
  • 电子邮件
  • 消息
  • 确认

当用户发布表单时,请不要向您的电子邮件发送邮件,而不是您需要创建随机确认代码(例如,使用uniqid):

$confirmation = uniqid();

然后将用户电子邮件,消息文本和确认代码添加到表格并向用户发送电子邮件:

$url = "http://".$_POST["SERVER_NAME"].
  "/confirmation.php?confirmation=$confirmation'>";
mail($email, "Confirmation", 
 "Please press the following link to confirm your message: 
 <a href='http://$url'>confirm</a>.");

confirmation.php文件中使用$_GET["confirmation"]变量,在表格中搜索匹配的记录,从中获取电子邮件和消息,并将此数据发送到您的电子邮箱。如果需要,可以在数据库之后删除条目。