2015-05-14 67 views
0

我在我的網站上使用電子郵件表格。我希望發送的郵件包含用戶輸入的郵件地址或標題爲「<a href="mailto:ENTERED_EMAIL?subject=re\:ENTERED_SUBJECT">」的html鏈接的標題中的「回覆」項。我想這樣做,所以檢查郵件的員工可以用我們的郵件客戶端來回答,而無需手動輸入地址。 不幸的是我不明白它的工作原理。這是我工作的客戶端,而不鏈接/回覆:如何在通過電子郵件形式發送的電子郵件中創建回覆鏈接?

$destination = '[email protected]'; 
$sender = '[email protected]'; 
$sendername = 'myhomepage.de'; 
$subject = 'Mitteilung des E-Mail Formulars'; 
$urlsuccesspage = 'http://myhomepage.de/kontakt.php#success'; 
$separator = ":\t"; // colon and tabulator 


if ($_SERVER['REQUEST_METHOD'] === "POST") { 
    $header = array(); 
    $header[] = "From: ".mb_encode_mimeheader($sendername, "utf-8", "Q")."<".$sender.">"; 
    $header[] = "MIME-Version: 1.0"; 
    $header[] = "Content-type: text/plain; charset=utf-8"; 
    $header[] = "Content-transfer-encoding: 8bit"; 
    $mailtext = ""; 
    foreach ($_POST as $name => $value) { 
     if (is_array($value)) { 
      foreach ($value as $singlevalue) { 
       $mailtext .= $name.$separator.$value. "\n"; 
      } 
     } else { 
      $mailtext .= $name.$separator.$value. "\n"; 
     } 
    } 
    mail(
     $destination, 
     mb_encode_mimeheader($subject, "utf-8", "Q"), 
     $mailtext, 
     implode("\n", $header) 
    ) or die("Die Mail konnte nicht gesendet werden."); 
    header("Location: $urlsuccesspage"); 
    exit; 
    } 

header("Content-type: text/html; charset=utf-8"); 

這些是我想要整合的值:

<input class="fieldvalue" type="text" name="Email" /> 
<select class="fieldvalue" name="Subject"> 
    <option value="Frage">Frage</option> 
    <option value="Feedback">Feedback</option> 
    <option value="technisch">technische Frage</option> 
    <option value="Sonstige">Sonstige</option> 
</select> 
+0

查看手冊http://php.net/manual/en/function.mail.php''Reply-To:'。 $ from,' –

+0

@ Fred-ii- 我已經嘗試添加'$ header [] =「Reply-To:」。$ _ POST ['Email'];'但它根本不發送郵件。 – FeuerlordOhsai

+0

'$ from = $ _POST ['Email'];'---''Reply-To:'。從$' –

回答

0

試試這個代碼

<?php 
 
if(isset($_POST['Submit'])){ 
 
$name=$_POST["txtname"]; 
 
$phone=$_POST["txtphone"]; 
 
$address=$_POST["txtaddress"]; 
 
$email=$_POST["txtemail"]; 
 
$comment=$_POST["txtcomment"]; 
 

 
$to ="[email protected]"; 
 
$from ="$email"; 
 
$subject = "Comments thru website"; 
 
$message="Dear Sir, You have received a comment thru your website. The details are as shown below: \n 
 

 
Name :"." ". $name." \n 
 
Address :"." ".$address." \n 
 
Email:"." ".$email." \n 
 
phone:"." ".$phone." \n 
 
Comment:"." ".$comment ; 
 

 

 
mail($to, "$subject", $message, "From: $from "); 
 
header("location: index.html"); 
 
} 
 
?>

**相應地更改提交的名稱。

相關問題