如何在通过电子邮件表单发送的电子邮件中创建回复链接?

时间:2015-05-14 12:19:25

标签: php html forms email variables

我在我的网站上使用电子邮件表格。我希望发送的邮件包含标题中的“回复”项目,其中包含用户输入的邮件地址或类似<a href="mailto:ENTERED_EMAIL?subject=re\:ENTERED_SUBJECT">的html链接。我想要这个,所以检查邮件的员工可以使用我们的邮件客户端回答,而无需手动输入地址。 不幸的是,我没有让它工作。这是我的工作客户端没有链接/回复:

$destination = 'mail@myhomepage.de';
$sender = 'webformular@myhomepage.de';
$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>

1 个答案:

答案 0 :(得分:0)

试试此代码

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

$to ="xx@yourdomain.com";
$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");
}
?>
&#13;
&#13;
&#13;

**相应更改字段名称。