PHP脚本将联系表单发送到收件箱

时间:2013-07-04 12:40:10

标签: php html

我创建了一个联系表单,我希望在点击提交按钮后将详细信息发送到我的收件箱。单击“提交”按钮将打开一个新的邮件页面(请参阅getfreepack.org)。我被告知我需要一个PHP脚本。我从网上复制了一个,但不太确定如何使用它对我有利。我很感激你的帮助。

$Name= $_REQUEST["Name"]; 
$Email = $_REQUEST["Email"]; 
$Phone = $_REQUEST["Phone"]; 
$JobTitle = $_REQUEST["Jobtitle"]; 
$KeySkills = $_REQUEST["Keyskills"]; 
$Attachment = $_REQUEST["Attachment"]; 

$to = "my email address@mail.com"; 
$subject = "Contact Form"; 

$message = "Name: " . $Name $message .= "\Email: " . $Email: $message .= "\n Phone: " . $ Phone; 
$message .= "\nSubject: " . $Subject; $message .= "\nCover Letter: " . $CoverLetter; 
$message .= "\n Attachment: " . $Attachment; $message .= "\nIP Adress: " . $_SERVER['REMOTE_ADDR']; 
$message .= "\nBrowser: " . $_SERVER['HTTP_USER_AGENT']; 
$message .= "\n\nMessage: " . $theMessage; 

$headers = "From: $theEmail";
$headers .= "\nReply-To: $theEmail"; 

$sentOk = mail($to,$subject,$message,$headers); 
echo "sentOk=" . $sentOk;

2 个答案:

答案 0 :(得分:1)

非常基本的一个是:

<?php
 $to = "someone@example.com";
 $subject = "Test mail";
 $message = "Hello! This is a simple email message.";
 $from = "someonelse@example.com";
 $headers = "From:" . $from;
 mail($to,$subject,$message,$headers);
 echo "Mail Sent.";
?> 

如果您想更进一步,请查看手册:http://php.net/manual/en/function.mail.php

干杯

答案 1 :(得分:-1)

您不需要php就可以将表单发送到您的电子邮件地址,使表格标签像这样:

  
    
      

&GT;&GT;行动= “的mailto:youremailaddress@whatever.com” &GT;       输入       输入