我可以将 mailto 的收件人设置为 php 字符串吗?

Can I set recipient of mailto to a php string?

是否可以将我的 mailto 收件人设置为 $email 字符串? 我的网站上有一个预订表格,我想在从中收到的邮件中有 2 个按钮 (Accept/Decline)。这些按钮应该会自动打开一封新电子邮件 windows,其中包含设置的正文和表单中的收件人电子邮件。我的问题是我无法将电子邮件从表单发送到 mailto 按钮。

有帮助就好了:)

 <?php
include dirname(dirname(__FILE__)).'/mail.php';

error_reporting (E_ALL ^ E_NOTICE);

$post = (!empty($_POST)) ? true : false;


if($post){
    $name = stripslashes($_POST['name']);
    $email = trim($_POST['email']);
    $phone = stripslashes($_POST['phone']);
    $amount = stripslashes($_POST['amount']);
    $date = stripslashes($_POST['date']);
    $time = stripslashes($_POST['time']);

    $message .= "Telefonnummer: ".$phone."\n<br />"."Personen: ".$amount."\n<br />"."Datum: ".$date."\n<br />"."Uhrzeit: ".$time."\n<br />";
    $message .= '<html><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><table border="0" cellspacing="0" cellpadding="0"><tr><td><a href="mailto:<?php $email?>?Subject=Reservierung 73BB&Body=Hiermit bestaetigen wir Ihre Reservierung in der ...." target="_blank" style="font-size: 16px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; background-color: #EB7035; border-top: 12px solid #EB7035; border-bottom: 12px solid #EB7035; border-right: 18px solid #EB7035; border-left: 18px solid #EB7035; display: inline-block;">Annehmen &rarr;</a></td></tr></table></td></tr></table></html>';
    $message .= '<html><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><table border="0" cellspacing="0" cellpadding="0"><tr><td><a href="mailto:<?php $email?>?Subject=Reservierung 73&Body=Leider müssen wir Ihre Reservierung ablehnen da wir schon ausgebucht sind" target="_blank" style="font-size: 16px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; background-color: #EB7035; border-top: 12px solid #EB7035; border-bottom: 12px solid #EB7035; border-right: 28px solid #EB7035; border-left: 18px solid #EB7035; display: inline-block;">Ablehnen &rarr;</a></td></tr></table></td></tr></table></html>';

$headers = "From: $name\r\n";
$headers .= "Reply-To: $email\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

    $mail = mail('tes@test.test', 'Reservierung', $message, $headers);

    if($mail){
        echo 'Ihre Reservierung wurde erfolgreich abgeschickt. Sie erhalten in kürze eine Bestätigung';
    }

}
?>

您不必再次打开 php 标签。只需添加斜线并连接您的变量。

$message .= '<html>...<a href="mailto:' . $email . '?...</html>';